This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +97
-0
lines changed Expand file tree Collapse file tree 1 file changed +97
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .BufferedReader ;
2
+ import java .io .IOException ;
3
+ import java .io .InputStreamReader ;
4
+
5
+ public class ccc10j3 {
6
+
7
+ public static void main (String [] args ) throws IOException {
8
+ BufferedReader in = new BufferedReader (new InputStreamReader (System .in ));
9
+
10
+ int a = 0 ;
11
+ int b = 0 ;
12
+
13
+ String str = in .readLine ();
14
+ String [] input ;
15
+ while (!str .equals ("7" )) {
16
+ input = str .split (" " );
17
+
18
+ switch (Integer .parseInt (input [0 ])) {
19
+ case 1 : {
20
+ if (input [1 ].equals ("A" )) {
21
+ a = Integer .parseInt (input [2 ]);
22
+ } else {
23
+ b = Integer .parseInt (input [2 ]);
24
+ }
25
+ break ;
26
+ }
27
+
28
+ case 2 : {
29
+ if (input [1 ].equals ("A" )) {
30
+ System .out .println (a );
31
+ } else {
32
+ System .out .println (b );
33
+ }
34
+ break ;
35
+ }
36
+
37
+ case 3 : {
38
+ if (input [1 ].equals ("A" ) && input [2 ].equals ("A" )) {
39
+ a = a + a ;
40
+ } else if (input [1 ].equals ("B" ) && input [2 ].equals ("B" )){
41
+ b = b + b ;
42
+ } else if (input [1 ].equals ("A" ) && input [2 ].equals ("B" )){
43
+ a = a + b ;
44
+ } else {
45
+ b = b + a ;
46
+ }
47
+ break ;
48
+ }
49
+
50
+ case 4 : {
51
+ if (input [1 ].equals ("A" ) && input [2 ].equals ("A" )) {
52
+ a = a * a ;
53
+ } else if (input [1 ].equals ("B" ) && input [2 ].equals ("B" )){
54
+ b = b * b ;
55
+ } else if (input [1 ].equals ("A" ) && input [2 ].equals ("B" )){
56
+ a = a * b ;
57
+ } else {
58
+ b = b * a ;
59
+ }
60
+ break ;
61
+ }
62
+
63
+ case 5 : {
64
+ if (input [1 ].equals ("A" ) && input [2 ].equals ("A" )) {
65
+ a = a - a ;
66
+ } else if (input [1 ].equals ("B" ) && input [2 ].equals ("B" )){
67
+ b = b - b ;
68
+ } else if (input [1 ].equals ("A" ) && input [2 ].equals ("B" )){
69
+ a = a - b ;
70
+ } else {
71
+ b = b - a ;
72
+ }
73
+ break ;
74
+ }
75
+
76
+ case 6 : {
77
+ if (input [1 ].equals ("A" ) && input [2 ].equals ("A" )) {
78
+ a = a / a ;
79
+ } else if (input [1 ].equals ("B" ) && input [2 ].equals ("B" )){
80
+ b = b / b ;
81
+ } else if (input [1 ].equals ("A" ) && input [2 ].equals ("B" )){
82
+ a = a / b ;
83
+ } else {
84
+ b = b / a ;
85
+ }
86
+ break ;
87
+ }
88
+
89
+ case 7 : {
90
+ break ;
91
+ }
92
+ }
93
+ str = in .readLine ();
94
+ }
95
+ }
96
+
97
+ }
You can’t perform that action at this time.
0 commit comments