C sharp - Cargar matriz usuarios

 
Vista:
sin imagen de perfil

Cargar matriz usuarios

Publicado por Alejandro (3 intervenciones) el 22/06/2017 17:59:00
buenas, necesito con un metodo, 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 loteria, por ahora tengo esto

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
    namespace Proyecto
{
    class Program
    {
        static void agregar(int[] lista, int cantidad, ref int tope)
        {//agrega un nuevo elemento a un array con tope
            lista[tope] = cantidad;
            tope++;
        }
 
 
        static void cargarjugada (int[,]m)
        {
            for (int fila=0; fila<m.GetLength(0); fila++)
            {
                for(int col=0; col<m.GetLength(1);col++)
                {
                    Console.Write("Ingrese su Jugada : ");
                    m[fila,col] = Convert.ToInt32(Console.ReadLine());
                }
                   }
        }
 
 
 
 
        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.WriteLine("\t\t1-Agregar apuesta");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\t\t2-Agregar apuesta sorpresa");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\t\t3-Eliminar Apuesta");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("\t\t4-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();
                            Console.Write("Ingrese Apellido: ");
                            apellido[tope] = Console.ReadLine();
                            cargarjugada(matriz);
                            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 cuantos apostantes son, si le pongo 2, cuando voy a generar la apuesta me pregunta nombre apellido y me deja poner 10 numeros en vez de solo 5 y que me vuelva a preguntar el nombre y apellido del 2do participante. En cambio si pongo que solo es 1 participante si, solamente me deja poner 5 bolillas, me faltara algun while en el switch del case 1? gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder