Advertisement
Primitiv0

3 Numbers Lottery

Sep 10th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. { srand(time(0));
  9.   int n1, n2, n3, u1, u2, u3;
  10.   n1 = (rand() % 100) + 1;
  11.   n2 = (rand() % 100) + 1;
  12.   n3 = (rand() % 100) + 1;
  13.  
  14.   cout << "Entre 3 números: " << endl;
  15.  
  16.   cin >> u1;
  17.   cin >> u2;
  18.   cin >> u3;
  19.  
  20.   int cantidad = 0;
  21.  
  22.   if(n1 == u1 || n1 == u2 || n1 == u3)
  23.     cantidad++;
  24.   if(n2 == u1 || n2 == u2 || n2 == u3)
  25.     cantidad++;
  26.   if(n3 == u1 || n3 == u2 || n3 == u3)
  27.     cantidad++;
  28.    
  29.   cout<< cantidad <<endl;
  30.  
  31.   switch(cantidad)
  32.   {
  33.       case 0: cout<< "Que lástima! Suerte para la próxima!"<<endl;
  34.             break;
  35.       case 1: cout<< "Felicidades! has acertado un número!"<<endl;
  36.             break;
  37.       case 2: cout<< "Felicidades! has ganado un Doble!!"<<endl;
  38.             break;
  39.       case 3: cout<< "Eres un feliz ganador de una Tripleta!!!"<<endl;
  40.             break;
  41.       default:///////
  42.       break;
  43.   }
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement