-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy path1133 - Array Simulation
More file actions
54 lines (48 loc) · 877 Bytes
/
1133 - Array Simulation
File metadata and controls
54 lines (48 loc) · 877 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
46
47
48
49
50
51
52
53
54
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
int n, m, i, j, value, value1, no = 1;
char x;
int a[105];
while(t--){
cin >> n >> m;
for(i = 0; i < n; i++)
cin >> a[i];
while(m--){
cin >> x;
if(x == 'S'){
cin >> value;
for(i = 0; i < n; i++)
a[i] = a[i] + value;
}
else if(x == 'M'){
cin >> value;
for(i = 0; i < n; i++)
a[i] = a[i]*value;
}
else if(x == 'D'){
cin >> value;
for(i = 0; i < n; i++)
a[i] = a[i]/ value;
}
else if(x == 'R'){
for(i = 0; i < n/2; i++)
swap(a[i],a[n-i-1]);
}
else if(x == 'P'){
cin >> value >> value1;
swap(a[value],a[value1]);
}
}
cout << "Case " << no << ":" << endl;
for(i = 0; i < n - 1; i++)
cout << a[i] << " ";
cout << a[n-1];
no++;
cout << endl;
}
return 0;
}