Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Rus");
- srand(time(0));
- int operation, x, x1, otvet, b;
- cout << "Виды операций:\n1-Сложение\n2-Вычитание\n3-Умножение\n4-Деление\n5-Выход\nВведите нужную вам операцию\n";
- cin >> operation;
- if (operation != 5) {
- while (operation != 5) {
- x = rand() % 100;
- x1 = rand() % 100;
- if (operation == 1) {
- otvet = x + x1;
- cout << x << "+" << x1 << "=";
- cin >> b;
- if (b == otvet) { cout << "Правильно\n"; }
- else { cout << "Неправильно\n"; }
- }
- if (operation == 2) {
- otvet = x - x1;
- cout << x << "-" << x1 << "=";
- cin >> b;
- if (b == otvet) { cout << "Правильно\n"; }
- else { cout << "Неправильно\n"; }
- }
- if (operation == 3) {
- otvet = x * x1;
- cout << x << "*" << x1 << "=";
- cin >> b;
- if (b == otvet) { cout << "Правильно\n"; }
- else { cout << "Неправильно\n"; }
- }
- if (operation == 4) {
- otvet = x / x1;
- cout << x << "/" << x1 << "=";
- cin >> b;
- if (b == otvet) { cout << "Правильно\n"; }
- else { cout << "Неправильно\n"; }
- }
- cout << "Виды операций:\n1-Сложение\n2-Вычитание\n3-Умножение\n4-Деление\n5-Выход\nВведите нужную вам операцию\n";
- cin >> operation;
- }
- }
- cout << "Завершение работы";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement