Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <time.h>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "russian");
- system("color 0A");
- srand(time(NULL));
- int i=0, guess, answer, wrongnum=0;
- double score, rightnum = 0, n;
- cout << "Введите кол-во примеров: ";
- cin >> n;
- while (i < n)
- {
- i++;
- int a = rand() % 100;
- int b = rand() % 100;
- if (a < 25)
- {
- cout << a << '+' << b << "= ";
- guess = a + b;
- }
- if (a > 25 && a < 50)
- {
- cout << a << '-' << b << "= ";
- guess = a - b;
- }
- if (a > 50 && a < 75)
- {
- cout << a << '*' << b << "= ";
- guess = a * b;
- }
- if (a > 75)
- {
- cout << a << '/' << b << "= (усекая) ";
- guess = a / b;
- }
- cin >> answer;
- if (guess == answer)
- {
- rightnum++;
- cout << "Верно, счет: правильно: " << rightnum << " \\ " << n << " неправильно: " << wrongnum << " \\ " << n <<endl;
- }
- else
- {
- wrongnum++;
- cout << "Неверно, счет: правильно: " << rightnum << " \\ " << n << " неправильно: " << wrongnum << " \\ " << n <<endl;
- }
- }
- score = rightnum / n * 100;
- if (rightnum>wrongnum)
- {
- cout << "Вы выграли! Ваш счет - " << score << "% правильных." << endl;
- }
- else
- {
- cout << "Вы проиграли! Ваш счет - " << score << "% правильных." << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment