Advertisement
Guest User

Untitled

a guest
Jul 27th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include<iostream>
  2. #include<ctime>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int a, b;
  8.     srand(time(0));
  9.     while (1) {
  10.         a = rand() % 16;
  11.         b = rand() % 16;
  12.         while (1) {
  13.             int c;
  14.             cout << hex << uppercase << a << " + " << b << " = ";
  15.             cin >> hex >> c;
  16.  
  17.             if (c == a + b) {
  18.                 cout << "Yes!" << endl;
  19.                 break;
  20.             }
  21.  
  22.             else if (c != a + b) {
  23.                 cout << "No!" << endl;
  24.                 continue;
  25.             }
  26.            
  27.         }
  28.        
  29.     }
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement