Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Windows only
- #include <iostream>
- #include <cstdlib>
- #include <Windows.h>
- #define FILLER (char)176// (char)176 (char)15 (char)253
- using namespace std;
- int srcTable[9][10] = {
- 1, 4, -1, -1, 0, 0, 0, 0, 0, 0,
- 0, -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 2, -1, 5, -1, -1, -1, 0, 0, 0,
- 0, -1, 0, -1, 0, 0, 0, 0, 0, 0,
- 0, -1, 0, 3, -1, -1, -1, 6, -1, -1,
- 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
- 0, 0, 0, -1, 0, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, -1, 0, 0
- };
- char isAnswered[9][10];
- char *Quest[] = {
- "Questions horizontally: ",
- " 1) **** can be storaged in strings ",
- " 2) R****e the string ",
- " 3) ******* can point to smth ",
- " ",
- "Questions vertically: ",
- " 4) A**** of symbols ",
- " 5) String is s**** class in C++ ",
- " 6) T**** of strings "
- };
- char *Answ[] = {
- "data",
- "resize",
- "pointer",
- "array",
- "super",
- "table"
- };
- void drawCros();
- int main()
- {
- char temp[80] = { 0 };
- int numQ = 0, rightAns = 0;
- const DWORD dwSize = 128;
- TCHAR buffer[dwSize];
- GetConsoleTitle(buffer, dwSize);
- HWND hwnd = FindWindow(NULL, buffer); // Узнаем hwnd окна
- MoveWindow(hwnd, 0, 0, 700, 550, true);
- for (int i = 0; i < 9; i++) // initialization of array
- for (int j = 0; j < 10; j++)
- isAnswered[i][j] = '0';
- do {
- drawCros();
- do {
- cin.clear();
- fflush(stdin);
- cout << "\n> Enter the number of a question or\n '-h' for help, '-x' for exit: ";
- cin.get(temp, 80);
- if (!(atoi(temp) > 0 && atoi(temp) <= 6) && strcmp(temp, "-h") && strcmp(temp, "-x"))
- cout << "\n> Allowed only digits(1 - 6), '-h' or '-x' . . .\n";
- } while (!(atoi(temp) > 0 && atoi(temp) <= 6) && strcmp(temp, "-h") && strcmp(temp, "-x"));
- if (!strcmp(temp, "-x")) {
- cout << "\n\t\t\tLittle shame =/\n\t\t\tGood bye!\n\n\t\t";
- system("pause");
- exit(0);
- }
- else if (!strcmp(temp, "-h")) {
- cout << "\nDictionary: \n\n ~ ";
- for (int i = 5; i >= 0; i--)
- cout << Answ[i] << " ~ ";
- cout << "\n\n";
- system("pause");
- }
- else {
- numQ = atoi(temp);
- cout << "\n> Now enter the word-answer: ";
- cin.clear();
- fflush(stdin);
- cin.get(temp, 80);
- for (int i = 0; temp[i]; i++)
- temp[i] = tolower(temp[i]);
- if (!(strcmp(Answ[numQ - 1], temp))) {
- cout << "\n> You are right!\n\n";
- system("pause");
- switch (numQ) {
- case 1:
- isAnswered[0][0] = 'D';
- isAnswered[0][1] = 'A';
- isAnswered[0][2] = 't';
- isAnswered[0][3] = 'a';
- break;
- case 2:
- isAnswered[2][1] = 'R';
- isAnswered[2][2] = 'e';
- isAnswered[2][3] = 'S';
- isAnswered[2][4] = 'i';
- isAnswered[2][5] = 'z';
- isAnswered[2][6] = 'e';
- break;
- case 3:
- isAnswered[4][3] = 'P';
- isAnswered[4][4] = 'o';
- isAnswered[4][5] = 'i';
- isAnswered[4][6] = 'n';
- isAnswered[4][7] = 'T';
- isAnswered[4][8] = 'e';
- isAnswered[4][9] = 'r';
- break;
- case 4:
- isAnswered[0][1] = 'A';
- isAnswered[1][1] = 'r';
- isAnswered[2][1] = 'R';
- isAnswered[3][1] = 'a';
- isAnswered[4][1] = 'y';
- break;
- case 5:
- isAnswered[2][3] = 'S';
- isAnswered[3][3] = 'u';
- isAnswered[4][3] = 'P';
- isAnswered[5][3] = 'e';
- isAnswered[6][3] = 'r';
- break;
- case 6:
- isAnswered[4][7] = 'T';
- isAnswered[5][7] = 'a';
- isAnswered[6][7] = 'b';
- isAnswered[7][7] = 'l';
- isAnswered[8][7] = 'e';
- break;
- }
- rightAns++;
- }
- else {
- cout << "\n> You are wrong!\n\n";
- system("pause");
- }
- }
- } while (rightAns < 6);
- drawCros();
- cout << "\n\n\n\t\t\tCongratulation! You're won!\n\n\n";
- cout << "\n";
- system("pause");
- return 0;
- }
- void drawCros()
- {
- system("cls");
- cout << "\t\t\t\t~Crossword~\n\n";
- for (int i = 0; i < 9; i++) {
- // Top border
- cout << " ";
- for (int j = 0; j < 10; j++) {
- if (srcTable[i][j])
- cout << (char)218 << (char)196 << (char)191;
- else
- cout << " ";
- }
- cout << "\n";
- // Middle
- cout << Quest[i];
- for (int j = 0; j < 10; j++) {
- if (srcTable[i][j]) {
- if (isAnswered[i][j] != '0')
- cout << (char)179 << isAnswered[i][j] << (char)179;
- else {
- if (srcTable[i][j] < 0) // draw void cell
- cout << (char)179 << FILLER << (char)179;
- else // draw number of question
- cout << (char)179 << srcTable[i][j] << (char)179;
- }
- }
- else
- cout << " ";
- }
- cout << "\n";
- // Bottom border
- cout << " ";
- for (int j = 0; j < 10; j++) {
- if (srcTable[i][j])
- cout << (char)192 << (char)196 << (char)217;
- else
- cout << " ";
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement