my/c++/l6.cpp

43 lines
854 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
#include <random>
#include <string>
int all() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int> distrib(1, 100);
int i = 0;
while(i <= 3) {
int x1 = distrib(gen);
int x2 = distrib(gen);
int x3 = x1+x2;
int pol;
std::cout << x1 << "+" << x2 << "=?" << std::endl;
std::cin >> pol;
if(pol == x3) {
std::cout << "Верно!" << std::endl;
std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
}
else {
std::cout << "Не верно!" << std::endl;
std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
return 0;
}
}
return 1;
}
int main() {
while(1) {
std::string polz;
std::cout << "1. Начать\n2. Закончить" << std::endl;
std::cin >> polz;
if(polz == "1") {
all();
}
else if(polz == "2") {
return 0;
}
}
return 0;
}