Advertisement
pan7nikt

zgadywanie

Dec 10th, 2019
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4. using namespace std;
  5.  
  6. int liczba;
  7. float input;
  8. int lpowt = 0;
  9.  
  10. bool correct;
  11.  
  12. main()
  13. {
  14.     srand(time(NULL));
  15.     liczba = rand()%1000;
  16.    
  17.     //do debugowania
  18.     //cout << liczba << endl;
  19.    
  20.     while (correct==false)
  21.     {
  22.         lpowt++;
  23.         cout << "podaj liczbe: ";
  24.         cin >> input;
  25.         cout << endl;
  26.        
  27.         if (input==liczba)
  28.         {
  29.             correct = true;
  30.             cout << "Dobrze!" << endl;
  31.             cout << "Udalo ci sie po " << lpowt << " probach" << endl;
  32.         }
  33.         if (input > liczba)
  34.         {
  35.             cout << "podana liczba jest zbyt wysoka" << endl;
  36.         }
  37.         if (input < liczba)
  38.         {
  39.             cout << "podana liczba jest zbyt niska" << endl;
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement