B3ar6

random - sumy

Sep 13th, 2020
708
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<ctime>
  3. #include<cstdlib>
  4. #include<windows.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int x, y, z, sum=0, a;
  10.     srand(time(NULL));
  11.     x= rand()%27+1;
  12.     y= rand()%27+1;
  13.     z= rand()%27+1;
  14.     sum = x+y+z;
  15.    
  16.     cout << "System wylosowal 3 cyfry z przedzialu 1-28, oto one: " << endl;
  17.     cout << "x wynosi: " << x << endl;
  18.     cout << "y wynosi: " << y << endl;
  19.     cout << "z wynosi: " << z << endl;
  20.     cout << "Ile wynosi ich suma?" << endl;
  21.    
  22.     while(a!=sum)
  23.     {
  24.         cout << "Suma to: ";
  25.         cin >> a;
  26.         if(a!=sum)
  27.         {
  28.             cout << "Zle! policz dokladnie!" << endl << endl;
  29.             Sleep(1500);
  30.         }
  31.     }
  32.    
  33.     return 0;
  34. }
RAW Paste Data