Necesito con un método cargar una matriz, que tenga la misma cantidad (filas) de apostantes que se pide al principio y 5 columnas que son 5 bolillas de la lotería. Por ahora tengo esto:
class Program
{
static void nuevo(int[] lista, int cantidad, ref int tope)
lista[tope] = cantidad;
tope++;
}
static void jugada (int[,]m, int napostante)
{
for(int col=0; col<m.GetLength(1);col++)
{
Console.Write(Jugada : ");
m[napostante,col] = Convert.ToInt32(Console.ReadLine());
}
}
static void Main(string[] args)
{
string[] nombre;
string[] apellido;
int opcion, tope = 0, cantidad;
bool seguir = true;
Console.WriteLine("Ingrese la cantidad de apostantes: ");
cantidad= Convert.ToInt32(Console.ReadLine());
int[] vector = new int[cantidad];
nombre = new string[cantidad];
apellido = new string[cantidad];
int[,] matriz = new int[cantidad, 5];
while (seguir)
{
Console.Clear();
Console.WriteLine("\t\t1-Agregar apuesta");
Console.WriteLine();
Console.Write("Ingrese opcion: ");
opcion = Convert.ToInt32(Console.ReadLine());
switch (opcion)
{
case 1:
Console.Clear();
Console.WriteLine("\t\t1 - Agregue una apuesta: ");
if (tope < nombre.Length)
{
Console.Write("Ingrese Nombre: ");
nombre[tope] = Console.ReadLine();
Console.Write("Ingrese Apellido: ");
apellido[tope] = Console.ReadLine();
cargarjugada(matriz, tope - 1);
agregar(vector, cantidad, ref tope);
}
else
{
Console.WriteLine("No hay mas cupos");
Console.ReadLine();
}
break;
Pero el tema es que al ejecutar el programa me pregunta cuántos apostantes son, le pongo 2, cuando voy a generar la apuesta me pregunta nombre apellido y se quiebra el ingresar el primer numero. Necesito que registre a cada napostante con su jugada ya que luego tengo que desplegar las jugadas de cada apostante, ver si alguien gano, etc.
¿Me faltará algún while
en el switch
del case 1? ¿Cómo puedo solucionar este problema?
Gracias