Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int num, tries, guess;
- //Randomizer
- srand(time(0));
- num = 1 + rand()%10;
- //Creates the random number.
- //Sets the tries at 3.
- tries = 3;
- //Loops the program while the user's guess isn't the number.
- do{
- //Allows user to input guess.
- cout << "Tom is Gay): ";
- cin >> guess;
- //Subtracts tries.
- if(guess == num - 3 || guess == num + 3){
- //If off by 3, displays "cold."
- cout << "You're cold! Try again.\n" << endl;
- tries = tries - 1;
- }
- else if(guess == num - 2 || guess == num + 2){
- //If off by 2, displays "warm."
- cout << "Warmer! Try again.\n" << endl;
- tries = tries - 1;
- }
- else if(guess == num - 1 || guess == num + 1){
- //Iff off by 1, displays "hot."
- cout << "Red hot! Try again.\n" << endl;
- tries = tries - 1;
- }
- else if(guess != num){
- //If off by 4 or more, displays "way off."
- cout << "You're WAY off. Try again.\n" << endl;
- tries = tries - 1;
- }
- else{
- //If you get it, you win!
- cout << "Eureka! You got it! Good job." << endl;
- system("pause");
- }
- if(tries == 0){
- //Closes program once the user runs out of tries.
- cout << "You've run out of tries. Tough luck scrub." << endl;
- system("pause");
- }
- }while(guess != num);
- int x;
- cin>>x;
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement