Advertisement
Guest User

Рабочий тест по матеше

a guest
Sep 19th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <ctime>
  4. #include <cstdlib>
  5. using namespace std;
  6. int main()
  7. {
  8. setlocale(LC_ALL, "Rus");
  9. srand(time(0));
  10. int operation, x, x1, otvet, b;
  11. cout << "Виды операций:\n1-Сложение\n2-Вычитание\n3-Умножение\n4-Деление\n5-Выход\nВведите нужную вам операцию\n";
  12. cin >> operation;
  13. if (operation != 5) {
  14. while (operation != 5) {
  15. x = rand() % 100;
  16. x1 = rand() % 100;
  17. if (operation == 1) {
  18. otvet = x + x1;
  19. cout << x << "+" << x1 << "=";
  20. cin >> b;
  21. if (b == otvet) { cout << "Правильно\n"; }
  22. else { cout << "Неправильно\n"; }
  23. }
  24. if (operation == 2) {
  25. otvet = x - x1;
  26. cout << x << "-" << x1 << "=";
  27. cin >> b;
  28. if (b == otvet) { cout << "Правильно\n"; }
  29. else { cout << "Неправильно\n"; }
  30. }
  31.  
  32. if (operation == 3) {
  33. otvet = x * x1;
  34. cout << x << "*" << x1 << "=";
  35. cin >> b;
  36. if (b == otvet) { cout << "Правильно\n"; }
  37. else { cout << "Неправильно\n"; }
  38. }
  39. if (operation == 4) {
  40. otvet = x / x1;
  41. cout << x << "/" << x1 << "=";
  42. cin >> b;
  43. if (b == otvet) { cout << "Правильно\n"; }
  44. else { cout << "Неправильно\n"; }
  45. }
  46. cout << "Виды операций:\n1-Сложение\n2-Вычитание\n3-Умножение\n4-Деление\n5-Выход\nВведите нужную вам операцию\n";
  47. cin >> operation;
  48. }
  49. }
  50. cout << "Завершение работы";
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement