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 TestNotSoX
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random genLL = new Random();
- int n;
- int ileLos;
- int[] tabLosowe;
- Console.WriteLine("***SuperSoft Company 3018 * **");
- Console.WriteLine("===========================================");
- Console.WriteLine("TOTOLOTEK");
- Console.WriteLine("===========================================");
- ileLos = 6; //totolotek podstawowy: 6 x <1,49>
- int ileLosPlus = 10; //z plusem: 10 x <1,100>
- int ileLosEuro = 5; //euro jacket 5 x <1,50>
- tabLosowe = new int[ileLos];
- int[] tabLosowePlus = new int[ileLosPlus];
- int[] tabLosoweEuro = new int[ileLosEuro];
- //losowanie
- Console.WriteLine("MULTILOTEK: Wylosowane liczby to:");
- tabLosowe[0] = genLL.Next(1, 50);
- int[] tabN = new int[ileLos];
- /* for (int i = 0; i < ileLos - 1; i++)
- {
- tabN[i] = genLL.Next(1, 50);
- foreach (var e in tabLosowe)
- if (!(e == tabN[i])) tabLosowe[i] = tabN[i];
- Console.WriteLine(tabLosowe[i]);
- }*/
- // bardziej elegancki
- /* for (int i = 0; i < ileLos; i++)
- {
- int losowa;
- bool unikalna;
- do //wartość dla "i"-tego miejsca
- {
- losowa = genLL.Next(1, 50);
- unikalna = true;
- for (int j = 0; j < i; j++)
- if (losowa == tabLosowe[j])
- unikalna = false;
- }
- while (unikalna == false);
- tabLosowe[i] = losowa;
- }
- Console.WriteLine("Się wylosowało...");
- foreach (int e in tabLosowe)
- Console.Write("{0}, ", e);
- Console.WriteLine("Koniec serii");
- */
- //wersja II -mniej elegancka
- LiczLosowe(genLL, ileLos, tabLosowe, 1, 49);
- Console.WriteLine("Się wylosowało II...");
- foreach (int e in tabLosowe)
- Console.Write("{0}, ", e);
- Console.WriteLine("Koniec serii");
- //teraz Plus
- LiczLosowe(genLL, ileLosPlus, tabLosowePlus, 1, 100);
- LiczLosowe(genLL, ileLosEuro, tabLosoweEuro, 1, 50);
- Console.WriteLine("Się wylosowało Plus...");
- foreach (int e in tabLosowePlus)
- Console.Write("{0}, ", e);
- Console.WriteLine("Koniec serii");
- Console.WriteLine("Się wylosowało Euro...");
- foreach (int e in tabLosoweEuro)
- Console.Write("{0}, ", e);
- Console.WriteLine("Koniec serii");
- Console.Write("aby zakończyć - wciśnij dowolny klawisz...");
- Console.ReadKey();
- }
- private static void LiczLosowe(Random genLL, int ileLos, int[] tabLosowe, int losowaMin, int losowaMax)
- {
- for (int i = 0; i < ileLos; i++)
- {
- tabLosowe[i] = genLL.Next(losowaMin, losowaMax+1);
- for (int j = 0; j < i; j++)
- if (tabLosowe[i] == tabLosowe[j])
- i--;
- }
- }
- static void Statystyka(int [] tabDane, ref int max, ref double srednia, ref int min)
- {
- min = max = tabDane[0];
- foreach (int e in tabDane)
- {
- if (e < min) min = e;
- if (e > max) max = e;
- }
- srednia = (max + min) / 2;
- }
- static void WyznaczMinPP(int[] tabDane, ref int min )
- {
- min = tabDane[0];
- foreach (int e in tabDane)
- if (e < min) min = e;
- }
- static void WyznaczMaxPP(int[] tabDane, ref int max)
- {
- max = tabDane[0];
- foreach (int e in tabDane)
- if (e > max) max = e;
- }
- static int WyznaczMin(int[] tabDane)
- {
- int min = tabDane[0];
- foreach (int e in tabDane)
- if (e < min) min = e;
- return min;
- }
- static int WyznaczMax(int[] tabDane)
- {
- int max = tabDane[0];
- foreach (var e in tabDane)
- if (e > max) max = e;
- return max;
- }
- static double LiczSrednia(int[] tabDanych)
- {
- int suma = 0;
- foreach (var e in tabDanych)
- suma += e;
- return suma / tabDanych.Length;
- }
- static int ZliczX(int[] tabLiczb, int x)
- {
- int ileX = 0;
- foreach (var e in tabLiczb)
- if (e == x) ileX++;
- return ileX;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement