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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <ctime>
#include <string.h>
#include <stdio.h>
void Movie ();
void Idiom ();
void Country ();
void generator(char& teka, char answer[], char output[],bool& penentu,int& cubaan);
int penentuan(char output[],char answer[]);
using namespace std;
const int size = 30;
int main ()
{
cout<<setw(55)<<"WELCOME TO CRYTOPGRAPHIC QUIZ GAMES!"<<endl;
cout<<setw(73)<<"You must try to guess which alphabet represents the other alphabet.";
cout<<endl<<endl;
cout<<setw(45)<<"You are currently in"<<endl<<setw(38)<<"LEVEL 1"<<endl;
const int MIN_VALUE = 1;
const int MAX_VALUE = 3;
int x;
char option,again;
unsigned seed = time(0);
srand (seed);
cout<<setw(58)<<"Your category have been choosen by computer :"<<endl;
x = (rand() % (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE;
do
{
switch (x)
{
case 1: cout<<setw(38)<<"MOVIES"<<endl;
Movie ();
break;
case 2: cout<<setw(38)<<"IDIOMS"<<endl;
Idiom ();
break;
case 3: cout<<setw(38)<<"COUNTRY"<<endl;
Country ();
break;
default :;
}
cout<<endl<<setw(48)<<"Do you want to play again?"<<endl;
cout<<setw(53)<<"Press Y if yes, press any key if no"<<endl;
cout<<setw(35)<<" ";
cin>>again;
}while(again == 'Y'||again == 'y');
return 0;
}
void Movie ()
{
//system("COLOR D");
char answer[size] = "THE SHAWSHANK REDEMPTION";
char cipher[size] = "GSV HSZDHSZMP IVWVNKGRLM";
char output[size] = "___ _________ __________";
char tekaan; bool penentu = false;
int TrueFalse, cubaan = 1;
cout <<endl<<setw(53)<< "Guess the following cipher by letter" << endl <<setw(47)<< "You have maximum 5 tries" << endl;
do
{
//system("CLS");
cout <<endl<<setw(47)<<"GSV HSZDHSZMP IVWVNKGRLM" << endl <<setw(47)<< "_ _ _ _ _ _ _ _ _ _ _" << endl;
cout << endl;
cout <<setw(47)<< output << endl <<endl;
cout << "Your try - " << cubaan << " : ";
cin >> tekaan;
tekaan = toupper(tekaan);
generator(tekaan, answer, output, penentu, cubaan);
cout << endl;
TrueFalse = penentuan(output, cipher);
if(TrueFalse == 1)
{
break;
}
else
{
}
}while(cubaan < 6);
if (TrueFalse == 1)
{
cout << " CONGRATULATION ! YOU'VE GOT IT ALL CORRECT ! " << endl;
}
else
{
cout <<setw(45)<< " Sorry, you're WRONG! " << endl;
cout <<setw(35)<< " The right answer : " << answer << endl;
}
//system("PAUSE");
}
void generator(char& teka, char answer[], char output[],bool& penentu,int& cubaan)
{
for (int i = 0; i < size; i++)
{
if (teka == answer[i])
{
output[i] = teka;
penentu = true;
}
}
if (!penentu)
{
cubaan++;
}
else
{
penentu = false;
}
}
int penentuan(char output[],char answer[])
{
int TrueFalse;
if (strcmp(output, answer) == 0)
{
TrueFalse = 1;
return TrueFalse;
}
else
{
TrueFalse = 0;
return TrueFalse;
}
}
void Idiom ()
{
//system("COLOR D");
char answer[size] = "CURIOSITY KILLS THE CAT";
char cipher[size] = "XFIRLHRGB PROOH GSV XZG";
char output[size] = "_________ _____ ___ ___";
char tekaan; bool penentu = false;
int cubaan = 1;
cout <<endl<<setw(53)<< "Guess the following cipher by letter" << endl <<setw(47)<< "You have maximum 5 tries" << endl;
while (cubaan < 6)
{
//system("CLS");
cout <<endl<<setw(46)<< "XFIRLHRGB PROOH GSV XZG" << endl <<setw(58)<<"_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ " << endl;
cout << endl;
cout <<setw(46)<< output << endl <<endl;
cout << "try - " << cubaan << " : ";
cin >> tekaan;
tekaan = toupper(tekaan);
generator(tekaan, answer, output, penentu, cubaan);
cout << endl;
}
if (penentuan(output, cipher))
{
cout << " CONGRATULATION ! YOU'VE GOT IT ALL CORRECT ! " << endl;
}
else
{
cout <<setw(45)<< " Sorry, you're WRONG! " << endl;
cout <<setw(33)<< " The right answer : " << answer << endl;
}
//system("PAUSE");
}
void Country ()
{
//system("COLOR D");
char answer[size] = "CROATIA";
char cipher[size] = "ZYVIEWI";
char output[size] = "_______";
char tekaan; bool penentu = false;
int cubaan = 1;
cout <<endl<<setw(53)<< "Guess the following cipher by letter" << endl <<setw(47)<< "You have maximum 5 tries" << endl;
while (cubaan < 6)
{
//system("CLS");
cout <<setw(38)<< "ZYVIEWI" << endl <<setw(42)<< "_ _ _ _ _ _ _ " << endl;
cout << endl;
cout <<setw(38)<< output << endl <<endl;
cout << "Your try - " << cubaan << " : ";
cin >> tekaan;
tekaan = toupper(tekaan);
generator(tekaan, answer, output, penentu, cubaan);
cout << endl;
}
if (penentuan(output, cipher))
{
cout << " CONGRATULATION ! YOU'VE GOT IT ALL CORRECT ! " << endl;
}
else
{
cout <<setw(45)<< " Sorry, you're WRONG! " << endl;
cout <<setw(40)<< " The right answer : " << answer << endl;
}
//system("PAUSE");
}
|