Advertisement
ItsMeLucifer

ZgadywanieLiczby C++

Mar 27th, 2019
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     for(;;){
  9.     int liczbalos;
  10.     srand(time(0));
  11.     liczbalos = rand() %100 +1;
  12.     int zgadl;
  13.     cout<<"Witamy w zgaduj zgadula, system wylosowal jedna liczbe z zakresu 1-100, sprobuj zgadnac ktora to!"<<endl;
  14.     do{
  15.         cin>>zgadl;
  16.         if(cin){
  17.         if(liczbalos>zgadl){
  18.             cout<<"Za malo!"<<endl;
  19.         }else if(liczbalos<zgadl){
  20.             cout<<"Za duzo!"<<endl;
  21.         }else{
  22.             cout<<"Brawo! Zgadles!"<<endl;
  23.         }
  24.         }else {cout<<"Bledna liczba!"<<endl; cin.clear(); cin.sync(); }
  25.     }while(zgadl!=liczbalos);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement