Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.           int guess, r;
  10.           double count = 0;
  11.           int loop = 0;
  12.           int level = 1;
  13.           int a = 10;
  14.           int b = 1;
  15.           int points = 0;;
  16.                
  17.           srand(time(0));
  18.           r = rand() % a + b;
  19.                
  20.           while (loop == 0)
  21.           {
  22.                 cout << "NOTE: Press Ctrl + Z to end the game." << endl << endl;
  23.                 cout << "Level: " << level << endl;
  24.                 cout << "Points: " << points << endl;
  25.                 cout << "I'm thinking of a number between " << b << " and " << a << ":";
  26.                 cin >> guess;
  27.                 ++count;
  28.                 system("CLS");
  29.                
  30.                 if (cin.eof())
  31.                 {
  32.                 cout << "Level Reached: " << level << endl;
  33.                 cout << "Total Points: " << points << endl;
  34.                 cout << "Guess Ratio: " << level/count << endl;
  35.                 system("PAUSE");
  36.                 return(0);
  37.                 }
  38.                 if (guess == r)
  39.                 {
  40.                 cout << guess << " is correct." << endl << endl;
  41.                 r = rand() % a + b;
  42.                 ++level;
  43.                 a = a + 5;
  44.                 points = points + 1000;
  45.                 continue;
  46.                 }                
  47.                 if (guess < r)
  48.                 {
  49.                 cout << guess << " is lower than the number I'm thinking of." << endl << endl;
  50.                 points = points - 100;
  51.                 continue;
  52.                 }              
  53.                 if (guess > r)
  54.                 {
  55.                 cout << guess << " is higher than the number I'm thinking of." << endl << endl;
  56.                 points = points - 100;
  57.                 continue;
  58.                 }
  59.                 else
  60.                 {
  61.                 system("CLS")
  62.                 continue;
  63.                 }  
  64.           return(0);
  65.           }
  66. }
  67.    
  68.           while (loop == 0)
  69.           {
  70.                 cout << "NOTE: Press Ctrl + Z to end the game." << endl << endl;
  71.                 cout << "Level: " << level << endl;
  72.                 cout << "Points: " << points << endl;
  73.                 cout << "I'm thinking of a number between " << b << " and " << a << ":";
  74.                 cin >> guess;
  75.                 ++count;
  76.                 system("CLS");
  77.                
  78.                 if (cin.eof())
  79.                 {
  80.                 cout << "Level Reached: " << level << endl;
  81.                 cout << "Total Points: " << points << endl;
  82.                 cout << "Guess Ratio: " << level/count << endl;
  83.                 system("PAUSE");
  84.                 return(0);
  85.                 }
  86.                 if (guess == r)
  87.                 {
  88.                 cout << guess << " is correct." << endl << endl;
  89.                 r = rand() % a + b;
  90.                 ++level;
  91.                 a = a + 5;
  92.                 points = points + 1000;
  93.                 continue;
  94.                 }                
  95.                 if (guess < r)
  96.                 {
  97.                 cout << guess << " is lower than the number I'm thinking of." << endl << endl;
  98.                 points = points - 100;
  99.                 continue;
  100.                 }              
  101.                 if (guess > r)
  102.                 {
  103.                 cout << guess << " is higher than the number I'm thinking of." << endl << endl;
  104.                 points = points - 100;
  105.                 continue;
  106.                 }  
  107.           return(0);
  108.           }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement