Show Array and Matrix

2

I am not able to show the array corresponding to the matrix, just ready the total of bets, but I do not see who corresponds:

I have this method:

static void mostrar(int[,] matriz) //MOSTRAR APUESTAS
    {
        for (int fila = 0; fila < matriz.GetLength(0); fila++)
        {
            for (int col = 0; col < matriz.GetLength(1); col++)
            {
                Console.Write(matriz[fila, col] + "\t");
            }
            Console.WriteLine();
        }
        Console.ReadLine();

and here I invoke it:

case 5://VER TODAS LAS APUESTAS
                    Console.WriteLine("\t\t5 - Ver listado de apuestas: ");


                    mostrar(matriz);

                    break;

This is the rest of the code to better understand what the program does, in case 1 load the data:

static void Main(string[] args)
    {

        string[] nombre;
        string[] apellido;
        int opcion, tope = 0, cantidad;
        bool seguir = true;





        Console.WriteLine("\t\t*****Bienvenidos al 5 de Oro*****");
        Console.WriteLine();
        Console.WriteLine();

        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.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\t\t1-Agregar apuesta");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("\t\t2-Agregar apuesta sorpresa");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("\t\t3-Eliminar Apuesta");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("\t\t    4-Ver numeros Cliente");
            Console.WriteLine("\t\t    5-Ver listado de apuestas");
            Console.WriteLine("\t\t    6-Ver numeros sin aciertos");
            Console.WriteLine("\t\t7-Salir");
            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().ToUpper().Trim();
                        Console.Write("Ingrese Apellido: ");
                        apellido[tope] = Console.ReadLine().ToUpper().Trim();
                        Console.Write("Ingrese su Jugada : ");

                        cargarjugada(matriz, tope);
                        agregar(vector, cantidad, ref tope);








                    }
                    else
                    {
                        Console.WriteLine("No hay mas cupos");
                        Console.ReadLine();
                    }



                    break;
    
asked by eleaefe 26.06.2017 в 21:08
source

1 answer

2

Your show function, only shows the bets, because at no time you are receiving the vector of bettors -

You say that I throw you an error when passing it, but you have not described what error or how you tried to pass it.

Without getting into whether what you are doing is correct or not, you should define the show function as:

static void mostrar(int[,] matriz, string[] apellidos)
{
    for (int fila = 0; fila < matriz.GetLength(0); fila++)
    {
        //para cada fila, mostrar el apellido del apostador
        Console.Writeln(apellidos[fila]);
        for (int col = 0; col < matriz.GetLength(1); col++)
        {
            Console.Write(matriz[fila, col] + "\t");
        }
        Console.WriteLine();
    }
    Console.ReadLine();

and call it as follows:

mostrar(matriz,apellido);
    
answered by 28.06.2017 / 15:47
source