Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Deus
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Ingrese la cantidad de operadores: ");
  14.             int cantidad = ingresoNumericoConControl();
  15.             Console.WriteLine("");
  16.             string[,] matriz = new string[cantidad, 3];
  17.             armarMatriz(matriz, cantidad);
  18.             Control(matriz, cantidad);
  19.             Console.ReadKey();
  20.  
  21.         }
  22.  
  23.         //Metodo del ingreso de cantidad
  24.         public static int ingresoNumericoConControl()
  25.         {
  26.             string ingreso_numero;
  27.             int numero;
  28.             bool bandera_numero;
  29.             do
  30.             {
  31.                 ingreso_numero = Console.ReadLine();
  32.                 bandera_numero = int.TryParse(ingreso_numero, out numero);
  33.                 if (!bandera_numero)
  34.                 {
  35.                     Console.Write("ERROR. Debe ingresar un valor númerico: ");
  36.                 }
  37.                 else if (numero <= 0)
  38.                 {
  39.                     Console.Write("ERROR. Debe ingresar un valor mayor a 0: ");
  40.                 }
  41.             } while (!bandera_numero || numero <= 0);
  42.             return numero;
  43.         }
  44.  
  45.         //Método para armar la matriz
  46.         public static string[,] armarMatriz(string[,] matriz, int cantidad)
  47.         {
  48.             for (int f = 0; f < cantidad; f++)
  49.             {
  50.                 //Ingreso el nº de legajo
  51.                 Console.Write("Ingrese el legajo de la persona Nº" + (f + 1) + ": ");
  52.                 string ingreso_legajo = Console.ReadLine();
  53.                 int legajo = Int32.Parse(ingreso_legajo);
  54.                 matriz[f, 0] = ingreso_legajo;
  55.                 //Ingreso el nombre
  56.                 Console.Write("Ingrese el nombre de la persona Nº" + (f + 1) + ": ");
  57.                 string ingreso_nombre = Console.ReadLine();
  58.                 matriz[f, 1] = ingreso_nombre;
  59.                 //Ingreso el codigo del area
  60.                 Console.Write("Ingrese el código de área de la persona Nº" + (f + 1) + ": ");
  61.                 bool bandera = true;
  62.                 do
  63.                 {
  64.                     string ingreso_codigo = Console.ReadLine().ToUpper();
  65.                     if (ingreso_codigo.Equals("A") || ingreso_codigo.Equals("B") || ingreso_codigo.Equals("C"))
  66.                     {
  67.                         bandera = true;
  68.                         matriz[f, 2] = ingreso_codigo;
  69.                     }
  70.                     else
  71.                     {
  72.                         bandera = false;
  73.                         Console.Write("Ingrese un área válida!:");
  74.                     }
  75.                 } while (bandera == false);
  76.             }
  77.             return matriz;
  78.         }
  79.         ////
  80.         public static string[,] Control(string[,] matriz, int cantidad)
  81.         {
  82.             int[,] conteo = new int[cantidad, 3];
  83.             int cod_a = 0;
  84.             int cod_b = 0;
  85.             int cod_c = 0;
  86.             for (int f = 0; f < cantidad; f++)
  87.             {
  88.                 if (matriz[f, 2].Equals("A"))
  89.                 {
  90.                     cod_a++;
  91.                 }
  92.                 else if (matriz[f, 2].Equals("B"))
  93.                 {
  94.                     cod_b++;
  95.                 }
  96.                 else if (matriz[f, 2].Equals("C"))
  97.                 {
  98.                     cod_c++;
  99.                 }
  100.                 conteo[f, 0] = cod_a;
  101.                 conteo[f, 1] = cod_b;
  102.                 conteo[f, 2] = cod_c;
  103.             }
  104.             for (int f = 0; f < cantidad; f++)
  105.             {
  106.                 Console.Clear();
  107.                 Console.WriteLine("Cantidad A: " + conteo[f, 0]);
  108.                 Console.WriteLine("Cantidad B: " + conteo[f, 1]);
  109.                 Console.WriteLine("Cantidad C: " + conteo[f, 2]);
  110.                 Console.WriteLine(" ");
  111.             }
  112.             return matriz;
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement