Commit b32e295a authored by Michael's avatar Michael

michael.davityan:exercise_06_35new

parent c5ef7019
Pipeline #25419561 passed with stage
in 1 minute and 8 seconds
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <unistd.h>
void printMessage(bool answerStatus);
......@@ -15,23 +14,25 @@ main()
std::srand(std::time(0));
}
bool answerStatus = true;
int number1 = 0;
int number2 = 0;
while (true) {
if (::isatty(STDIN_FILENO)) {
std::cout << "How much is ";
}
if (answerStatus) {
int number1 = 1 + std::rand() % 10;
int number2 = 1 + std::rand() % 10;
number1 = 1 + std::rand() % 10;
number2 = 1 + std::rand() % 10;
}
if (::isatty(STDIN_FILENO)) {
std::cout << Number1 << " * " << Number2 << "?: ";
std::cout << number1 << " * " << number2 << "?: ";
}
int answer;
std::cin >> answer;
if (-1 == answer) {
break;
}
answerStatus = (answer == Number1 * Number2);
answerStatus = (answer == number1 * number2);
printMessage(answerStatus);
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment