Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int num1, num2;
- char mat;
- cin >> num1 >> num2 >> mat;
- if (num1 != 0 && num2 != 0)
- {
- if (mat == '+')
- {
- int num = num1 + num2;
- if (num % 2 == 0)
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - even" << endl;
- }
- else
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - odd" << endl;
- }
- }
- else if (mat == '-')
- {
- int num = num1 - num2;
- if (num % 2 == 0)
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - even" << endl;
- }
- else
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - odd" << endl;
- }
- }
- else if (mat == '*')
- {
- int num = num1 * num2;
- if (num % 2 == 0)
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - even" << endl;
- }
- else
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - odd" << endl;
- }
- }
- else if (mat == '/')
- {
- double num = num1 / num2;
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << fixed << setprecision(2) << num << endl;
- }
- else if (mat == '%')
- {
- double num = num1 % num2;
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << endl;
- }
- }
- else
- {
- if (mat == '+')
- {
- int num = num1 + num2;
- if (num % 2 == 0)
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - even" << endl;
- }
- else
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - odd" << endl;
- }
- }
- else if (mat == '-')
- {
- int num = num1 - num2;
- if (num % 2 == 0)
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - even" << endl;
- }
- else
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - odd" << endl;
- }
- }
- else if (mat == '*')
- {
- int num = num1 * num2;
- if (num % 2 == 0)
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - even" << endl;
- }
- else
- {
- cout << num1 << ' ' << mat << ' ' << num2 << " = " << num << " - odd" << endl;
- }
- }
- else if (mat == '/')
- {
- cout << "Cannot divide " << num1 << " by zero" << endl;
- }
- else if (mat == '%')
- {
- cout << "Cannot divide " << num1 << " by zero" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment