Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Deus
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Ingrese la cantidad de operadores: ");
- int cantidad = ingresoNumericoConControl();
- Console.WriteLine("");
- string[,] matriz = new string[cantidad, 3];
- armarMatriz(matriz, cantidad);
- Control(matriz, cantidad);
- Console.ReadKey();
- }
- //Metodo del ingreso de cantidad
- public static int ingresoNumericoConControl()
- {
- string ingreso_numero;
- int numero;
- bool bandera_numero;
- do
- {
- ingreso_numero = Console.ReadLine();
- bandera_numero = int.TryParse(ingreso_numero, out numero);
- if (!bandera_numero)
- {
- Console.Write("ERROR. Debe ingresar un valor númerico: ");
- }
- else if (numero <= 0)
- {
- Console.Write("ERROR. Debe ingresar un valor mayor a 0: ");
- }
- } while (!bandera_numero || numero <= 0);
- return numero;
- }
- //Método para armar la matriz
- public static string[,] armarMatriz(string[,] matriz, int cantidad)
- {
- for (int f = 0; f < cantidad; f++)
- {
- //Ingreso el nº de legajo
- Console.Write("Ingrese el legajo de la persona Nº" + (f + 1) + ": ");
- string ingreso_legajo = Console.ReadLine();
- int legajo = Int32.Parse(ingreso_legajo);
- matriz[f, 0] = ingreso_legajo;
- //Ingreso el nombre
- Console.Write("Ingrese el nombre de la persona Nº" + (f + 1) + ": ");
- string ingreso_nombre = Console.ReadLine();
- matriz[f, 1] = ingreso_nombre;
- //Ingreso el codigo del area
- Console.Write("Ingrese el código de área de la persona Nº" + (f + 1) + ": ");
- bool bandera = true;
- do
- {
- string ingreso_codigo = Console.ReadLine().ToUpper();
- if (ingreso_codigo.Equals("A") || ingreso_codigo.Equals("B") || ingreso_codigo.Equals("C"))
- {
- bandera = true;
- matriz[f, 2] = ingreso_codigo;
- }
- else
- {
- bandera = false;
- Console.Write("Ingrese un área válida!:");
- }
- } while (bandera == false);
- }
- return matriz;
- }
- ////
- public static string[,] Control(string[,] matriz, int cantidad)
- {
- int[,] conteo = new int[cantidad, 3];
- int cod_a = 0;
- int cod_b = 0;
- int cod_c = 0;
- for (int f = 0; f < cantidad; f++)
- {
- if (matriz[f, 2].Equals("A"))
- {
- cod_a++;
- }
- else if (matriz[f, 2].Equals("B"))
- {
- cod_b++;
- }
- else if (matriz[f, 2].Equals("C"))
- {
- cod_c++;
- }
- conteo[f, 0] = cod_a;
- conteo[f, 1] = cod_b;
- conteo[f, 2] = cod_c;
- }
- for (int f = 0; f < cantidad; f++)
- {
- Console.Clear();
- Console.WriteLine("Cantidad A: " + conteo[f, 0]);
- Console.WriteLine("Cantidad B: " + conteo[f, 1]);
- Console.WriteLine("Cantidad C: " + conteo[f, 2]);
- Console.WriteLine(" ");
- }
- return matriz;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement