l6.cpp 854 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <iostream>
  2. #include <random>
  3. #include <string>
  4. int all() {
  5. std::random_device rd;
  6. std::mt19937 gen(rd());
  7. std::uniform_int_distribution<int> distrib(1, 100);
  8. int i = 0;
  9. while(i <= 3) {
  10. int x1 = distrib(gen);
  11. int x2 = distrib(gen);
  12. int x3 = x1+x2;
  13. int pol;
  14. std::cout << x1 << "+" << x2 << "=?" << std::endl;
  15. std::cin >> pol;
  16. if(pol == x3) {
  17. std::cout << "Верно!" << std::endl;
  18. std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
  19. }
  20. else {
  21. std::cout << "Не верно!" << std::endl;
  22. std::cout << x1 << "+" << x2 << "=" << x3 << std::endl;
  23. return 0;
  24. }
  25. }
  26. return 1;
  27. }
  28. int main() {
  29. while(1) {
  30. std::string polz;
  31. std::cout << "1. Начать\n2. Закончить" << std::endl;
  32. std::cin >> polz;
  33. if(polz == "1") {
  34. all();
  35. }
  36. else if(polz == "2") {
  37. return 0;
  38. }
  39. }
  40. return 0;
  41. }