K1u Posted January 21, 2008 Share Posted January 21, 2008 Coded for competition - http://k0h.org/portal/index.php?option=com...mp;topic=1792.0 #include <cstdlib> #include <iostream> /* K1u's Guessing Game. Author: K1u. Site: k0h.org. Description: Defines a random number that the user must attempt to guess. Disclaimer: I am not responsible for any damages this program my create. I am not responsible for how you use this program. */ using namespace std; int numGuesses = 3; /* Define the number of guesses. */ void game(void) { /* Declaration of variables. */ int guessedNum; /* Guessed Number. The number you input. */ string choice; /* Choice for playing again. */ cout << "What is the random number?n" << "It is a number from 1 to 5!n"; cin >> guessedNum; /* If the number is less or equal to 5 and greater 0 the program will proceed. */ if (guessedNum <= 5 && guessedNum > 0) { /* Seeding of the Random Number Generator. */ srand(time(NULL)); int rnum = rand() % 5 + 1; if (guessedNum == rnum) { cout << "Correct!n"; } else if (guessedNum != rnum) { /* If the number guessed is not correct then decrease the number of guesses. */ numGuesses--; cout << "Incorrect!n"; cout << "You only have " << numGuesses << " more guesses left!n"; /* If the number of guesses the user has made is less or equal to 0 then game over. */ if (numGuesses <= 0) { cout << "Bye!n"; } else { game(); } } } /* If the number is greater than 5 and less than 0. */ else { cout << "Number must be between 1 and 5.n"; cout << "Wish to play again?n" << "Yes or Non"; cin >> choice; if (choice == "Yes") { game(); } else { cout << "Bye!n"; } } } int main(void) { /* We call upon the function game. */ game(); system("pause"); return 0; } Quote Link to comment Share on other sites More sharing options...
snakey Posted January 21, 2008 Share Posted January 21, 2008 Funny how your posting an entry of a compitition of which the runner of it is banned. Quote Link to comment Share on other sites More sharing options...
SomeoneE1se Posted January 21, 2008 Share Posted January 21, 2008 first you ban him then you steal his game?! n00b! MSN != forums that's an abuse of power Quote Link to comment Share on other sites More sharing options...
VaKo Posted January 21, 2008 Share Posted January 21, 2008 If only I was allowed to do that... Quote Link to comment Share on other sites More sharing options...
snakey Posted January 22, 2008 Share Posted January 22, 2008 K1u unblock me so i can keep announce the winner and get the game rolling again. Quote Link to comment Share on other sites More sharing options...
K1u Posted January 23, 2008 Author Share Posted January 23, 2008 K1u unblock me so i can keep announce the winner and get the game rolling again. Fine... sorry I got mad at you... I will unban when I get home. Quote Link to comment Share on other sites More sharing options...
sablefoxx Posted January 24, 2008 Share Posted January 24, 2008 I was at school, bored so i did it on my TI-83 PLus calculator Ti-83 Plus Code: goto 0 .:By Sablefoxx:.: Lbl 0 ClrHome DelVar X DelVar Y randInt(1,100)->X Disp "I am thinking" Disp " of a Number" Disp "Between" input "1 and 100: ", Y goto 5 Lbl 5 If Y=X goto 1 If Y>X goto 2 If Y<X goto 3 Lbl 1 ClrHome Disp "You Win it Was", X pause goto 0 Lbl 2 Clr Home Disp "You Are Wrong" Disp "It is Lower then", Y pause goto 4 Lbl 3 ClrHome Disp "Wrong! Guess" Disp "Higher then", Y pause goto 4 Lbl 4 ClrHome DelVar Y input "Guess Again: ", Y goto 5 NOTE: to get the '->' on line 5 use the 'STO->' key above 'ON' and you do not type out commands you must choose them from a menu, most can found in the CATALOG To make it start calc press PRGM then Press the '-->' until "new" is highlighted press ENTER, press [TAN] [5] [sIN] [LN] [LN] to name it "GUESS" type in code above if you cannot find a certain command try pressing '2nd' then 0 to bring up the CATALOG with just about every Ti-83 command in it. To Run it goto your home (press 2nd [MODE]) press [PRGM] and select "GUESS" from the menu. Good Luck! Enjoy and happy slacking! Quote Link to comment Share on other sites More sharing options...
sc0rpi0 Posted January 28, 2008 Share Posted January 28, 2008 I was at school, bored so i did it on my TI-83 PLus calculator Ti-83 Plus Code: goto 0 .:By Sablefoxx:.: Lbl 0 ClrHome DelVar X DelVar Y randInt(1,100)->X Disp "I am thinking" Disp " of a Number" Disp "Between" input "1 and 100: ", Y goto 5 Lbl 5 If Y=X goto 1 If Y>X goto 2 If Y<X goto 3 Lbl 1 ClrHome Disp "You Win it Was", X pause goto 0 Lbl 2 Clr Home Disp "You Are Wrong" Disp "It is Lower then", Y pause goto 4 Lbl 3 ClrHome Disp "Wrong! Guess" Disp "Higher then", Y pause goto 4 Lbl 4 ClrHome DelVar Y input "Guess Again: ", Y goto 5 NOTE: to get the '->' on line 5 use the 'STO->' key above 'ON' and you do not type out commands you must choose them from a menu, most can found in the CATALOG To make it start calc press PRGM then Press the '-->' until "new" is highlighted press ENTER, press [TAN] [5] [sIN] [LN] [LN] to name it "GUESS" type in code above if you cannot find a certain command try pressing '2nd' then 0 to bring up the CATALOG with just about every Ti-83 command in it. To Run it goto your home (press 2nd [MODE]) press [PRGM] and select "GUESS" from the menu. Good Luck! Enjoy and happy slacking! cool Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.