Advertisement
nm9505

Console Sort Game

Sep 9th, 2022
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | Gaming | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Deployment;
  4. using System.Text;
  5. using System.Collections.Generic;
  6.  
  7. class Sorteo
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         int[] C = new int[10];
  12.         Console.Write("Ingrese Indice de sorteo: ");
  13.         int N = int.Parse(Console.ReadLine());
  14.         string[,] entero = new string[N,5];
  15.         for(int j=1; j<=N; j++)
  16.         {
  17.             var bolas = "10210231023456789102345678910234567893456789456789";
  18.             var sorteo = new char[5];
  19.             var bola = new Random();
  20.             for (int i = 0; i < sorteo.Length; i++)
  21.             {
  22.                 entero[j-1,i] = Convert.ToString(bolas[bola.Next(bolas.Length)]);
  23.                 Console.Write($"{entero[j-1,i]}");
  24.             }
  25.             Console.Write(" ");
  26.         }
  27.         Console.WriteLine();
  28.         int max1=0; int max2=0; int[] c = new int[10];int m=0; int n=0;
  29.         Console.ForegroundColor = ConsoleColor.Green;
  30.         for (int r=0; r<10; r++)
  31.         {
  32.             for (int j=0; j<N; j++)
  33.             {
  34.                 if (entero[j,4]==$"{r}")
  35.                 {
  36.                     ++C[r];
  37.                 }
  38.             }
  39.             if (max1<C[r])
  40.             {
  41.                 max1 = C[r];
  42.                 m = r;
  43.             }
  44.            
  45.             Console.WriteLine($"Enteros que terminan en {r} son {C[r]}");
  46.         }
  47.         for (int k=0; k<10; k++)
  48.         {
  49.             if(k==m){continue;}
  50.             if (max2<C[k])
  51.             {
  52.                 max2 = C[k];
  53.                 n=k;
  54.             }
  55.         }
  56.         Console.WriteLine($"Terminación {m} con {max1} repeticiones.");
  57.         Console.WriteLine($"Terminación {n} con {max2} repeticiones.");
  58.         Console.ForegroundColor = ConsoleColor.Green;
  59.     }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement