Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Multiplier.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <time.h>
- #include <conio.h>
- #include <ctype.h>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- int answer = -1;
- //Switching the console to cyrillic
- setlocale(LC_ALL, "Russian");
- int first, second, mult;
- //Setting random function seed based in time
- srand(time(0));
- first = rand() % 9 + 1;
- second = rand() % 9 + 1;
- mult = first * second;
- cout << "Сколько будет " << first << " x " << second << " ?" << "\n";
- cin >> answer;
- //In case if user inputed some negative number or not-digit character(answer variable still be equel to -1)
- if(answer < 0)
- cout << "Ошибка: Ответ должен быть положительным числом";
- else
- {
- if(answer != mult)
- cout << "Умри, неверный! " << first << " x " << second << " = " << mult;
- else
- cout << "Правильно!";
- }
- cout << "\n\nНажмите любую клавишу для выхода...";
- //Suspending the console
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment