-
Notifications
You must be signed in to change notification settings - Fork 0
/
UVA11360.cpp
executable file
·80 lines (72 loc) · 1.96 KB
/
UVA11360.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
using namespace std;
int matriz[11][11];
void increase(int n){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
matriz[i][j] += 1;
if(matriz[i][j] == 10) matriz[i][j] = 0;
}
}
}
void decrease(int n){
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
matriz[i][j] -= 1;
if(matriz[i][j] == -1) matriz[i][j] = 9;
}
}
}
void changeRow(int a, int b, int n){
for(int i = 0; i < n; i++) swap(matriz[a][i], matriz[b][i]);
}
void changeCol(int a, int b, int n){
for(int i = 0; i < n; i++) swap(matriz[i][a], matriz[i][b]);
}
void transpose(int n){
for(int i = 0; i < n; i++){
for(int j = i + 1; j < n; j++) swap(matriz[i][j], matriz[j][i]);
}
}
int main(){
int tc, n, op, cont = 0;
string opS;
cin >> tc;
while(cont < tc){
cin >> n;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++) scanf("%1d", &matriz[i][j]); //Para tomar un solo numero
}
cin >> op;
while(op-- > 0){
cin >> opS;
if(opS == "inc") increase(n);
else if(opS == "dec") decrease(n);
else if(opS == "transpose") transpose(n);
else if(opS == "row"){
int a, b;
cin >> a >> b;
a--;
b--;
changeRow(a, b, n);
}else if(opS == "col"){
int a, b;
cin >> a >> b;
a--;
b--;
changeCol(a, b, n);
}
}
printf("Case #%d\n", cont + 1);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++) printf("%d", matriz[i][j]);
printf("\n");
}
printf("\n");
cont++;
}
return 0;
}