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
|
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#include <cstdlib>
using namespace std;
int main()
{
cout << "Welcome to the Pi Game!\n";
system("Pause");
system("CLS");
cout << "In this game, you will input characters of pi until you get one wrong.\nWhen you get one wrong, you lose.\n";
system("Pause");
system("CLS");
cout << "Please input the digits one at a time.\n";
system("Pause");
system("CLS");
cout << "You will have 30 seconds to memorize as many digits of pi as you can, starting with the next click of a button.\n";
system("Pause");
system("CLS");
cout << "3.14159265358979323846264338\n3279502884197169399375105820\n9749445923078164062862089986\n2803482534211706798214808651\n3282306647093844609550582231\n7253594081284811174502841027\n0193852110555964462294895493\n038196";
_sleep(30000);
system("CLS");
cout << "Begin (you do need to put in the decimal.\n";
int positionInPi;
char userInput;
char pi[202];
for(int x = 0; x <= 201; x++)
{
positionInPi = 0;
userInput = 0;
char pi[202] {3,'.',1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5,0,2,8,8,4,1,9,7,1,6,9,3,9,9,3,7,5,1,0,5,8,2,0,9,7,4,9,4,4,5,9,2,3,0,7,8,1,6,4,0,6,2,8,6,2,0,8,9,9,8,6,2,8,0,3,4,8,2,5,3,4,2,1,1,7,0,6,7,9,8,2,1,4,8,0,8,6,5,1,3,2,8,2,3,0,6,6,4,7,0,9,3,8,4,4,6,0,9,5,5,0,5,8,2,2,3,1,7,2,5,3,5,9,4,0,8,1,2,8,4,8,1,1,1,7,4,5,0,2,8,4,1,0,2,7,0,1,9,3,8,5,2,1,1,0,5,5,5,9,6,4,4,6,2,2,9,4,8,9,5,4,9,3,0,3,8,1,9,6};
cin >> userInput;
if (pi[positionInPi] != userInput)
{
break;
}
positionInPi++;
}
cout << "Game Over!\n";
cout << "You knew " << positionInPi+1 << " digits of pi.\n";
return 0;
}
|