Advertisement
forest98

Superenalotto

Jan 23rd, 2015
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Superenalotto
  2. Copyright (c) 2014-2015 Emanuele Forestieri.All rights reserved.
  3.  
  4. Changelog:
  5. #0.5 [24/05/2015]
  6. -ottimizzato il codice
  7.  
  8. #0.4 [14/02/2015]
  9. -Ottimizzato il codice tramite l'utilizzo di matrici
  10. -Grafica migliorata
  11.  
  12. #0.3 [09/02/2015]
  13. -Risolti bug
  14.  
  15. #0.2 [08/02/2015]
  16. -Ottimizzato il codice
  17. -Risolti bug
  18. -Adesso prima giochi e poi estrai
  19. -Grafica migliorata
  20.  
  21. #0.1 [23/01/2015]
  22. -Realease iniziale
  23. */
  24. #include <cstdlib>
  25. #include <iostream>
  26. #include <windows.h>
  27. #include <time.h>
  28. #include <conio.h>
  29.  
  30. unsigned int i,j;
  31.  
  32. using namespace std;
  33.  
  34. void Controllo(unsigned int& a,unsigned int v[][2])
  35. {
  36.     for (j=0;j<a;j++)
  37.     {
  38.         if (v[a][1]==v[j][1])
  39.         {
  40.             cout << "Numero gia' inserito\n";
  41.             a--;
  42.         }
  43.     }
  44. }
  45.  
  46. void Genera(unsigned int v2[][2])
  47. {
  48.     srand(time(0));
  49.     for (i=0;i<8;i++)
  50.     {
  51.         v2[i][0]=rand()%90+1;
  52.         for (j=0;j<i;j++)
  53.             if (v2[i][0]==v2[j][0])
  54.                 i--;
  55.     }
  56. }
  57.  
  58. void Ordina(unsigned int v3[][2],unsigned int n)
  59. {
  60.     unsigned int t;
  61.     for (i=0;i<6;i++)
  62.     {
  63.         for (j=i+1;j<6;j++)
  64.         {
  65.             if (v3[i][n]>v3[j][n])
  66.             {
  67.                 t=v3[i][n];
  68.                 v3[i][n]=v3[j][n];
  69.                 v3[j][n]=t;
  70.             }
  71.         }
  72.     }
  73. }
  74.  
  75. int main()
  76. {
  77.     unsigned int s;
  78.     system("color a");
  79.     system("title Superenalotto");
  80.     do
  81.     {
  82.         system("cls");
  83.         cout << "                                ***************" << endl;
  84.         cout << "                                *SUPERENALOTTO*" << endl;
  85.         cout << "                                ***************" << endl;
  86.         cout << "\nMENU':";
  87.         cout << "\n1-->GIOCA";
  88.         cout << "\n2-->ESCI";
  89.         cout << "\n\nSCEGLI:";
  90.         cin >> s;
  91.         if (s==1)
  92.         {
  93.             unsigned int ni=0;
  94.             unsigned int n[8][2];
  95.             system("cls");
  96.             cout << "Numeri Giocati\n\n";
  97.             for (i=0;i<6;i++)
  98.             {
  99.                 do
  100.                 {
  101.                     cout << "Numero " << i+1 << ":";
  102.                     cin >> n[i][1];
  103.                     if (n[i][1]<1 || n[i][1]>90)
  104.                         cout << "Il numero deve essere compreso tra 1 e 90\n";
  105.                 }
  106.                 while(n[i][1]<1 || n[i][1]>90);
  107.                 Controllo(i,n);
  108.                 if (i==5)
  109.                 {
  110.                     i++;
  111.                     do
  112.                     {
  113.                         if (i<6)
  114.                             i++;
  115.                         cout << "Numero jolly:";
  116.                         cin >> n[6][1];
  117.                         if (n[6][1]<1 || n[6][1]>90)
  118.                             cout << "Il numero jolly deve essere compreso tra 1 e 90\n";
  119.                         else
  120.                             Controllo(i,n);
  121.                     }
  122.                     while (n[6][1]<1 || n[6][1]>90 || i!=6);
  123.                     i++;
  124.                     do
  125.                     {
  126.                         if (i<7)
  127.                             i++;
  128.                         cout << "Numero superstar:";
  129.                         cin >> n[7][1];
  130.                         if (n[7][1]<1 || n[7][1]>90)
  131.                             cout <<"Il numero superstar deve essere compreso tra 1 e 90\n";
  132.                         else
  133.                             Controllo(i,n);
  134.                     }
  135.                     while (n[7][1]<1 || n[7][1]>90 || i!=7);
  136.                 }
  137.             }
  138.             cout << "\nPremi invio per vedere l'estrazione in diretta live";
  139.             getch();
  140.             system("cls");
  141.             cout << "Numeri Giocati\n\n";
  142.             Ordina(n,1);
  143.             for (i=0;i<6;i++)
  144.                 cout << "Numero " << i+1 << ":" << n[i][1] << endl;
  145.             cout << "Numero jolly:" << n[6][1] << endl;
  146.             cout << "Numero superstar:" << n[7][1] << endl;
  147.             cout << "\nEstrazione Live\n\n";
  148.             Genera(n);
  149.             for (i=0;i<6;i++)
  150.             {
  151.                 cout << "Numero " << i+1 << ":";
  152.                 Sleep(2000);
  153.                 cout << n[i][0] << endl;
  154.             }
  155.             cout << "Numero jolly:";
  156.             Sleep(2000);
  157.             cout << n[6][0] << endl;
  158.             cout << "Numero superstar:";
  159.             Sleep(2000);
  160.             cout << n[7][0] << endl << endl;
  161.             Ordina(n,0);
  162.             for (i=0;i<6;i++)
  163.             {
  164.                 for (j=0;j<6;j++)
  165.                 {
  166.                     if (n[i][0]==n[j][1])
  167.                     {
  168.                         cout << "Hai indovinato il numero " << n[i][0] << endl;
  169.                         ni++;
  170.                     }
  171.                 }
  172.             }
  173.             if (ni==0)
  174.                 cout << "Non hai indovinato nessun numero\n";
  175.             if (n[6][0]==n[6][1] || n[7][0]==n[7][1])
  176.             {
  177.                 if (n[6][0]==n[6][1] && n[7][0]==n[7][1])
  178.                     cout << "Hai indovinato il numero jolly e superstar\n";
  179.                 else if (n[6][0]==n[6][1])
  180.                     cout << "Hai indovinato il numero jolly\n";
  181.                 else
  182.                     cout << "Hai indovinato il numero superstar\n";
  183.             }
  184.             cout << endl;
  185.             cout << "Premi invio per tornare al menu'...";
  186.             getch();
  187.         }
  188.         else if (s==2)
  189.         {
  190.             cout << "\nTorna a giocare quando vuoi :D";
  191.             Sleep(1500);
  192.         }
  193.         else
  194.         {
  195.             cout << "\nScelta non valida, riprova";
  196.             Sleep(1500);
  197.         }
  198.     }
  199.     while (s!=2);
  200.     return 0;
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement