Advertisement
nm9505

Sorted List

Oct 3rd, 2023
1,156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 2.25 KB | Science | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.IO;
  4. using Mono.CSharp;
  5. using Android.Widget;
  6. using Android.Content;
  7. using Android.Views.InputMethods;
  8. using System.Threading.Tasks;
  9. using NativeUiLib; //This ads the GUI contols. Minor abstractions over Xamarin.Android/Mono.Android
  10. namespace SORTED
  11. {
  12.     public static class Program
  13.     {
  14.         public static async void Main()
  15.         {
  16.             var Bolas = "01234567890987654321012345678901234567890123456789";
  17.             string lista = null;
  18.             int[] sf = new int[10];
  19.             int z=0;
  20.             var sort = new char[5]; var bola = new Random();
  21.             var lay1 = new LinearLayout();
  22.             //lay1.Orientation = Android.Widget.Orientation.Vertical;
  23.            
  24.             var lbl = lay1.AddTextView();
  25.             var valor = lay1.AddEditText(true);
  26.            
  27.            
  28.             //var lay2 = new LinearLayout();
  29.             //lay2.Orientation = Android.Widget.Orientation.Horizontal;
  30.             int N = 50000;
  31.             var btn = lay1.AddButton();
  32.             var btn1 = lay1.AddButton();
  33.             var lbl1 = lay1.AddTextView();
  34.            
  35.             lbl1.SetPadding(4,5,5,0);
  36.             if (valor.Text != "")
  37.             {
  38.                 N = Convert.ToInt32(valor.Text);
  39.             }
  40.             string[] sorteo = new string[N];
  41.             lbl.Text = " Xamarin.Forms/Mono.Android/App ";
  42.             btn.Text = " SORTEAR ";
  43.             btn1.Text = " BORRAR ";
  44.             lay1.Show(); Console.Clear();
  45.             //lay2.Show();
  46.             await Task.Delay(300);
  47.             btn.Click += delegate
  48.             {
  49.                 if (valor.Text != "")
  50.                 {
  51.                     N = Convert.ToInt32(valor.Text);
  52.                 }
  53.                 lista = null;
  54.                 for(int j=0; j<N; j++)
  55.                 {
  56.                     for (int i=0; i < sort.Length; i++)
  57.                     {
  58.                         sort[i] = Bolas[bola.Next(Bolas.Length)];
  59.                     }
  60.                     sorteo [j] = new String(sort);
  61.                 }
  62.                 for(int k=0; k<N; k++)
  63.                 {
  64.                     lista = lista + sorteo[k] + "  ";
  65.                 }
  66.                 for (int i=0; i<10; i++)
  67.                 {
  68.                     sf[i]=0; z=0;
  69.                     for(int j=0; j<N; j++)
  70.                     {
  71.                         string x = Convert.ToString(sorteo[j][4]);
  72.                         if (x == $"{i}")
  73.                         {
  74.                             z++;
  75.                         }
  76.                     }
  77.                     sf[i]=z;
  78.                 }
  79.                 lbl1.Text = $"Terminaciones de 0, 1, 2, 3, 4, 5, 6, 7, 8 y 9 respectivamente:\n {sf[0]},{sf[1]},{sf[2]},{sf[3]},{sf[4]},{sf[5]},{sf[6]},{sf[7]},{sf[8]},{sf[9]}\n\n" + lista;
  80.             };
  81.             btn1.Click += delegate
  82.             {
  83.                 lbl1.Text = "";
  84.                 valor.Text = "";
  85.                 N=0;
  86.                 for (int i=0; i<10; i++)
  87.                 {
  88.                     sf[i]=0;
  89.                 }
  90.             };
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement