Phoenix_x

Untitled

Dec 22nd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int T1[100][6], T2[100][6], T3[100][6];
  8.  
  9. void GenTir(int tir)
  10. {
  11.     int n, c, a[n];
  12.     bool equiv;
  13.     for (int n = 0; n<6; n++) {
  14.         cout << "\n Vuvedete " <<n+1<< " chislo za tegleneto : " ;  cin>>a[n] ;
  15.     }
  16.     for (n = 0; n<6; n++)
  17.     {
  18.         do
  19.         {
  20.             T1[tir][n] = 1 + rand() % 49;
  21.             equiv = false;
  22.             for (c = 0; c<n; c++)
  23.                 if (T1[tir][c] == T1[tir][n]) equiv = true;
  24.         } while (equiv);
  25.     }
  26.     for (n = 0; n<6; n++)
  27.     {
  28.         do
  29.         {
  30.             T2[tir][n] = 1 + rand() % 49;
  31.             equiv = false;
  32.             for (c = 0; c<n; c++)
  33.                 if (T2[tir][c] == T2[tir][n]) equiv = true;
  34.         } while (equiv);
  35.     }
  36.     for (n = 0; n<6; n++)
  37.     {
  38.         do
  39.         {
  40.             T3[tir][n] = 1 + rand() % 49;
  41.             equiv = false;
  42.             for (c = 0; c<n; c++)
  43.                 if (T3[tir][c] == T3[tir][n]) equiv = true;
  44.         } while (equiv);
  45.     }
  46. }
  47.  
  48. void Gen(void)
  49. {
  50.     int t;
  51.     for (t = 0; t<1; t++)
  52.         GenTir(t);
  53. }
  54.  
  55. void BrIzZaVsTeglene(int tegl)
  56. {
  57.     int tg;
  58.     cout << endl << "Nomer na teglene (1-3): "; cin >> tg; while (tg<1 || tg>3);
  59.     int Br[49] = { 0 }, t, n;
  60.     for (t = 0; t<100; t++)
  61.         for (n = 0; n<6; n++)
  62.         {
  63.             if (tegl == 1) Br[T1[t][n] - 1]++;
  64.             if (tegl == 2) Br[T2[t][n] - 1]++;
  65.             if (tegl == 3) Br[T3[t][n] - 1]++;
  66.         }
  67.     for (n = 0; n<49; n++)
  68.         cout << "Chisloto " << 1 + n << " e iztegleno " << Br[n] << " puti" << endl;
  69. }
  70.  
  71. void DesetNayChesto(void)
  72. {
  73.     int Br[49] = { 0 }, t, n, index, maxbr;
  74.     for (t = 0; t<100; t++)
  75.         for (n = 0; n<6; n++)
  76.         {
  77.             Br[T1[t][n] - 1]++;
  78.             Br[T2[t][n] - 1]++;
  79.             Br[T3[t][n] - 1]++;
  80.         }
  81.     for (n = 0; n<10; n++)
  82.     {
  83.         index = 0;
  84.         maxbr = Br[index];
  85.         for (t = 0; t<49; t++)
  86.             if (Br[t]>maxbr)
  87.             {
  88.                 index = t; maxbr = Br[t];
  89.             }
  90.         cout << "Chisloto" << 1 + index << " e iztegleno " << Br[index] << " puti" << endl;
  91.         Br[index] = 0;
  92.     }cout << endl << endl;
  93. }
  94.  
  95. void Analize(void)
  96. {
  97.     int ch, tegl;
  98.     do
  99.     {
  100.         cout << endl << endl << "1. Kolichestva na vsichki chisla" << endl;
  101.         cout << "2. 10 nay chesto izteglqni" << endl;
  102.         cout << "3. Glavno menu" << endl << endl;
  103.         do
  104.         {
  105.             cout << "Your choice: ";
  106.             cin >> ch;
  107.         } while (ch<0 || ch>3);
  108.         switch (ch)
  109.  
  110.         {
  111.         case 1: BrIzZaVsTeglene(tegl); break;
  112.         case 2: DesetNayChesto(); break;
  113.         }
  114.  
  115.     } while (ch != 3);
  116. }
  117. void Izvejdane(void)
  118. {
  119.     int tir, n;
  120.     cout << endl << "Tiraj (1-100): "; cin >> tir;
  121.     cout << endl << "I-vo teglene:" << endl;
  122.     for (n = 0; n<6; n++)
  123.         cout << T1[tir][n] << " ";
  124.     cout << endl << "II-ro teglene:" << endl;
  125.     for (n = 0; n<6; n++)
  126.         cout << T2[tir][n] << " ";
  127.     cout << endl << "III-to teglene:" << endl;
  128.     for (n = 0; n<6; n++)
  129.         cout << T3[tir][n] << " ";
  130.     cout << endl << endl;
  131. }
  132.  
  133. int main()
  134. {
  135.  
  136.     srand(time(NULL));
  137.     cout << "TOTO 6 / 49" << endl;
  138.     int ch;
  139.     do {
  140.         cout << "\n\t Menu\n";
  141.         cout << "\n 1.Generirane";
  142.         cout << "\n 2.Analiz";
  143.         cout << "\n 3.izvejdane na chisla za tiraj T i teglene I-III";
  144.         cout << "\n 4.Exit";
  145.         do {
  146.             cout << "\n Your choice:";
  147.             cin >> ch;
  148.         } while (ch<1 || ch>4);
  149.         switch (ch)
  150.         {
  151.         case 1: Gen(); break;
  152.         case 2: Analize(); break;
  153.         case 3: Izvejdane(); break;
  154.         case 4:;
  155.         }
  156.  
  157.     } while (ch != 4);
  158.     return 0;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment