Advertisement
hiker43

randomnumber

Aug 31st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using std::cout;
  5. using std::cin;
  6.  
  7. int main()
  8. {
  9.    srand(time(0));
  10.    int a = rand()%10+1;
  11.  
  12.  
  13.  
  14.    cout<<"\t\t\tPogoduvanje random broj"<<"\n";
  15.  
  16.    for (int i=0; i < 3; i++)
  17.    {
  18.  
  19.  
  20.        int broj;
  21.        cout<<"Vnesi broj:\t";
  22.        cin>>broj;
  23.  
  24.  
  25.  
  26.            if (a > broj)
  27.            {
  28.                if ( i==2)
  29.  
  30.               {
  31.                   cout<<"Ne go pogodivte brojot";
  32.  
  33.               }
  34.               else
  35.               {
  36.                cout<<"Baraniot broj e pogolem:\t";
  37.               }
  38.            }
  39.            else if(a < broj)
  40.               {
  41.                if ( i ==2)
  42.                {
  43.                    cout<<"Ne go pogodivte brojot";
  44.                }
  45.                else
  46.                {
  47.                    cout<<"Baraniot broj e pomal";
  48.                }
  49.  
  50.               }
  51.               else
  52.               {
  53.  
  54.                 cout<<"Go pogodivte brojot";
  55.                 break;
  56.               }
  57.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement