// A PROJECT BY GINNI TANEJA AND AANCHAL MAHESHWARI
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<dos.h>
#include<string.h>
#include<graphics.h>
// delay function delays the output of next command
void hard () // to print stars and rows
{
char position[] = {'A', 'B', 'C', 'D', 'E'} ;
gotoxy (43, 3);
cout<<'F'<<'\n';
for (int i=4, j=0, o=1, p=0; i<=32, j<5; i+=4, j++, o++, p++)
{
for (int k=43, m=0; k<=80, m<5; k+=8, m++)
{
gotoxy (k, i);
cout<<'*'<<':';
}
gotoxy (k-45, i);
cout<<position[p]<<'-';
cout<<'\n';
}
}
void menu () // to print the clues
{
cout<<"______________________________"<<'\n'<<'\n'<<
" ACROSS"<<'\n'<<'\n'<<"A. The highest possible square."<<'\n'<<
"B. The lowest possible square."<<'\n'
<<"C. The first three digits are"<<'\n'<<" cube of prime number and"
<<'\n'<<" last two digits are square"<<'\n'<<" of the same."<<
'\n'<<"D. The highest possible cube."<<'\n'
<<"E. Cube of a prime number."<<'\n'<<'\n'<<
"________________________________"<<'\n'<<'\n'<<
" DOWN"<<'\n'<<'\n'<<"F. The highest possible cube."<<'\n'
<<"________________________________"<<'\n'<<'\n'<<
" HOW TO PLAY"<<'\n'<<'\n'<<"1. Enter yor desired row i.e."<<'\n'<<
" 'A', 'B', 'C', 'D' or 'E' for"<<'\n'<<" Across and 'F' for down."<<'\n'<<
"2. Enter your number."<<'\n'<<
"3. If you want to quit,"<<'\n'<<" enter 'Q', and if you"<<'\n'<<
" want to submit, enter 'S'."; // instructions to play the game
}
int Process ()
{
New:
char ch, choice, result, position[] = {'A', 'B', 'C', 'D', 'E'}, position2[] = {'a', 'b', 'c', 'd', 'e'};
long no[6]={0,0,0,0,0,0}, b, c, d, e, f, ans[6]={99856, 71289, 34349, 35937, 68921, 97336};
int y;
Start:
gotoxy(37, 22);
cout<<"->"<<"Enter position alphabet"<<": "; // for the user to play
gotoxy(37, 23);
cout<<" ";
gotoxy(63, 22);
ch=getche();
getch();
if ((ch!='Q')&&(ch!='q')&&(ch!='A')&&(ch!='a')&&(ch!='B')&&(ch!='b')
&&(ch!='C')&&(ch!='c')&&(ch!='D')&&(ch!='d')&&(ch!='E')&&(ch!='e')&&(ch!='F')&&(ch!='f')&&(ch!='S')&&(ch!='s'))
goto Start; // entering alphabet again
if ((ch=='Q')||(ch=='q')) // game ends
exit (0);
if ((ch=='S')||(ch=='s')) // answers are submitted
{
clrscr();
for (y=0, result='Y'; y<5; y++) // checkings the answers
{
if (no[y]!=ans[y]) // comparing the submitted answers from the original answers
result='N';
}
gotoxy (30, 6);
if (result=='Y')
{
cout<<"You Win";
delay(3000);
exit (0);
}
else
cout<<"You Lose";
delay(1000);
gotoxy (20, 9);
cout<<"Press 'R' to see the solution "; // solutions will be shown
gotoxy (20, 10);
cout<<"or 'E' to exit : "; // program will end
Do:
cin>>choice;
if ((choice=='R')||(choice=='r')) //checking the choice entered
{
gotoxy (1, 13); // printing solution
cout<<"A. The highest possible square = 99856"<<'\n'<<
"B. The lowest possible square = 71289"<<'\n'
<<"C. The first three digits are cube of prime number and the last two digits are square of the same = 34349"<<
'\n'<<"D. The highest possible cube = 35937"<<'\n'
<<"E. Cube of a prime number = 68921"<<'\n'<<"F. The highest possible cube = 97336";
goto Do; // choice is to be entered
}
if ((choice=='E')||(choice=='e'))
exit (0);
else
goto Do;// choice is to be entered
}
again: // for entering numbers
gotoxy(37, 23);
cout<<"->"<<"Enter your number "<<": ";
if ((ch=='F')||(ch=='f')) // entering the number in F (down)
{
gotoxy(63, 23);
cin>>no[5];
long K= no[5];
if(K>99999)
goto again; // the no. is to be entered again
else
b=no[5]; // entered no. is saved in variable b
for (int i=46, j=4, k=0, number=10000; j<=32, k<5; j+=4, k++, number/=10)
{
int a=b/number; // to enter the 5digit no. down the grid
b%=number;
gotoxy (i,j);
cout<<a<<" ";
}
e=no[5];
for (int n=0, num=10000; n<5; n++, num/=10)
{
c = e / num;
e = e % num;
d = no[n]%10000;
no[n] = (c*10000) + d; // number is saved in the array- no
}
}
else
for (int i=38, j=4, m=0, n=0; i<=80, j<=32, m<5, n<5; j+=4, m++, n++)
{
if ((ch==position[n])||(ch==position2[n])) // position of entered alphabet is checked
{
gotoxy(63, 23);
cin>>no[n];
long K=no[n];
if(K>99999)
goto again; // no. is to be entered again if it is >99999
b=no[n]; //no. is saved in variable b
for (int k=0, l=i+8, number=10000; k<5; l+=8, k++, number/=10)
{
int a=b/number;
b%=number;
gotoxy (l,j);
cout<<a<<" "; // each digit of the no.is printed in each column of specified position
}
}
}
goto Start; // the process is started again
}
void screen1()
{
clrscr (); //to print the output of first screen
char CH;
delay(1000);
gotoxy (30, 4);
cout<<"MATHEMATICAL PUZZLE";
delay(2500);
gotoxy (21, 7);
cout<<"So you think you are a Maths Wizard?!?";
delay(2500);
gotoxy (25, 9);
cout<<"Let us see";
delay(600);
cout<<'.';
delay(600);
cout<<'.';
delay(600);
cout<<'.';
delay(1500);
cout<<"here's the test!";
delay(2500);
gotoxy (22, 11);
cout<<"Press 'S' to start or 'E' to exit : ";
dobara:
gotoxy (58, 11);
cin>>CH; // choice is to be entered
if ((CH=='E')||(CH=='e'))
exit (0);
if ((CH!='S')&&(CH!='s'))
goto dobara;
clrscr ();
}
void screen2() // for printing the output of screen2
{
delay(1000);
gotoxy (22, 5);
cout<<" HOW TO PLAY"; // instructions to play the game
delay(2000);
gotoxy (15, 7);
cout<<"1. Enter yor desired row i.e.";
gotoxy (15, 8);
cout<<" 'A', 'B', 'C', 'D' or 'E' for Across and 'F' for down.";
delay(4000);
gotoxy (15, 10);
cout<<"2. Enter your number.";
delay(3000);
gotoxy (15, 12);
cout<<"3. If you want to quit, enter 'Q'";
gotoxy (15, 13);
cout<<" and if you want to submit, enter 'S'.";
delay(6000);
clrscr ();
}
void screen3 () // for printing the output of screen3
{
for (int i=0; i<3; i++)
{
gotoxy (28, 14);
cout<<"Loading";
gotoxy (35, 14);
delay(800);
gotoxy (37, 14);
delay(800);
gotoxy (39, 14);
delay(800);
clrscr ();
}
}
main () // the execution begins from here
{
clrscr ();
screen1 ();
screen2 ();
screen3 ();
menu ();
hard ();
Process ();
getch ();
}
// HERE ARE THE OUTPUT SCREENS
No comments:
Post a Comment