Advertisement
szkoleniaTIK

Zgadnij liczbę

Mar 11th, 2021
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int los, liczba=0, licznik=1, napis=1;
  10.     srand(time(NULL));
  11.     los=rand()%100;
  12.     cout<<"Wymyslilem liczbe dla Ciebie :) w zakresie do 100"<<endl;
  13.     cout<<"Zgadnij liczbe w maksymalnie 6 probach: "<<endl;
  14.     do
  15.     {
  16.        cout<<"Proba nr: "<<licznik<<endl;
  17.        if (licznik>6)
  18.        {
  19.            cout<<"ZA DUZO PROB"<<endl;
  20.            cout<<"Zgadywana liczba to: "<<los<<endl;
  21.            napis=0;
  22.            break;
  23.        }
  24.        cin>>liczba;
  25.        if (los==liczba) break;
  26.        if (los<liczba) cout<<"Proponujesz za duza liczbe"<<endl;
  27.        if (los>liczba) cout<<"Proponujesz za mala liczbe"<<endl;
  28.        licznik++;
  29.        }
  30.     while (los!=liczba);
  31.     if (napis==1)cout<<"Brawo!!! Zgadles liczbe!!! :) w "<<licznik<<" probach!"<<endl;
  32.     return 0;
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement