1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main ()
{
cout << "Think of a number between 0 and 10. Now let me try and guess it." << endl;
int a,b,y,n;
y = 90;
n = 60;
bool c;
/*planned values for variables:
a= their number
b= their value for if random number is true or false
if b=Y,y then c=true
if b=N,n then c=false
if c= true then "congrat i win"
if c= false then "boo i lose, lemme guess again" */
srand ( time(NULL) );
cout << endl;
cout << "Input your number. Don't worry, I wont know it." << endl;
//Here im going to set a limit on the input of the number so that it is between 1 and 10
cout << endl;
cout << "Your Number: ";
cin >> a;
cout << endl;
if (a >= 10 && a >= 1)
//If the number is out of the bounds, then I will have a message appearing for them to put in a number between 1 and 10.
{
cout << "Sorry, " << a << " is either too high or too low. Using a number out of the range of 0" <<endl << "and 10 will make this program inoperable and will cause it to exit. Please try" <<endl << "again." << endl;
cout << endl;
cout << "Your Number (Between 0 and 10): ";
cin >> a;
if (a >= 10 && a >= 1)
{
cout << endl;
cout << "The program will now exit." << endl << endl;
system("pause");
exit(0);
}
}
printf ("Is the number %d", rand () % 10);
cout << endl;
cout << endl;
cout << "y/n: ";
cin >> b;
cout << endl;
//Here I'll make it so that b is true or false
if (b = 90)
{
c = true;
}
if (b = 60)
{
c = false;
}
if (c = true)
//if c is true then say "wow i figureed out the number or something
{
cout << "Yes! I succefully guessed your number!" << endl;
//I would like to include an "it only took *#* many tries for me to guess it!"
}
if (c = false)
//if c is false, then go back and and ask random number, but dont repeat numbers if possible
{
cout << endl;
cout << "Hmm, that was wrong, let me try again.";
}
cout << endl;
system ("pause");
return 0;
}
| |