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
|
#include<iostream.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#define g gotoxy
void main(){
int a,l,b,guess,row,col,answer,num,clue=5;
textcolor(YELLOW);
clrscr();
randomize();
a=random(30)+1;
b=random(100)+20;
num=random(a)+b;
clrscr();
for(col=1;col<=79;col++)
{
g(col,19);
cout<<"Í";
g(col,21);
cout<<"Í";
}
for(row=1;row<=50;row++)
{
g(1,20);
cout<<"º";
g(79,20);
cout<<"º";
}
for(col=1;col<=77;col++)
{
g(2,18);
cout<<"Wait while the game is loading..."<<endl;
g(col+1,20);
cout<<">";
delay(100);
}
do{
clrscr();
g(15,15);
cout<<"Guess the number!";
g(15,17);
cout<<"Clue: The number is between:\t"<<a <<"\tand\t" <<b+a;
g(15,19);
cout<<"Remaining number of trials:\t"<<clue;
textcolor(GREEN);
if((guess<num))
cout<<"\n\nEnter higher!";
if((guess>num)&&(clue<5))
cout<<"\n\nEnter lower!";
g(17,22);
cout<<"\nYour estimate is:";
cin>>guess;
if(guess!=num)
textcolor(CYAN);
clue--;
if(guess==num)
{
textcolor(MAGENTA);
clue=0;
l=1;
cout<<"Wow! You're right! The number is\t" << num;
}
}while(clue!=0);
if(l==0)
cout<<"\nSorry,you failed to guess the number, the number is\t" << num;
cout<<"\n---------------------------------------------------------";
cout<<"\n\tWould you like to play again?[Y/N]";
cin>>answer;
if((answer='N')||(answer='n'))
clrscr();
textcolor(GREEN);
cout<<"\n\n\n\n\t\tYou have chosen to quit. Thanks for playing!"<<endl;
getch();
}
|