-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrange_calc.c
More file actions
45 lines (43 loc) · 836 Bytes
/
strange_calc.c
File metadata and controls
45 lines (43 loc) · 836 Bytes
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
#include "stdio.h"
#include "string.h"
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int a, b;
char* s;
scanf("%d %s %d", &a, s, &b);
if(!strcmp(s,"ADD\0"))
{
printf("%d", a+b);
}
else if(!strcmp(s, "SUB\0"))
{
printf("%d", a-b);
}
else if(!strcmp(s, "MUL\0"))
{
printf("%d", a*b);
}
else if(!strcmp(s, "DIV\0"))
{
printf("%d", a/b);
}
else if(!strcmp(s, "OR\0"))
{
printf("%d", a|b);
}
else if(!strcmp(s, "AND\0"))
{
printf("%d", a&b);
}
else if(!strcmp(s, "XOR\0"))
{
printf("%d", a^b);
}
puts("");
}
return 0;
}