-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
59 lines (55 loc) · 1.3 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
using namespace std;
int main(){
int user_ch;
cin >> user_ch;
if(user_ch == 1){
float a, b, c, d, e;
cin >> a >> b >> c >> d;
e = (a+b+c+d)/4;
cout << e;
}else if(user_ch == 2){
int a, b;
cin >> a >> b;
if (a < 0 || b < 0){
cout << "NaN";
}else{
int field = (a * b) /2;
cout << field;
}
}else if(user_ch == 3){
int calc_op;
int n1, n2;
cin >> calc_op >> n1 >> n2;
if(calc_op == 1){
int result = n1 + n2;
cout << result;
}
else if(calc_op == 2){
int result = n1 - n2;
cout << result;
}
else if(calc_op == 3){
int result = n1 * n2;
cout << result;
}
else if(calc_op == 4){
if(n1 == 0 || n2 == 0){
cout << "NaN";
}else{
int result = n1 / n2;
cout << result;
}
}
else if(calc_op == 5){
if(n1 == 0 || n2 == 0){
cout << "NaN";
}else{
int result = n1 % n2;
cout << result;
}
}
}else{
cout << "Wrong task number.";
}
}