-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmrcooper.c
More file actions
53 lines (47 loc) · 758 Bytes
/
mrcooper.c
File metadata and controls
53 lines (47 loc) · 758 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
#include<stdio.h>
void main()
{
int n,t;
scanf("%d",&n);
int a[n*n];
int i,j=0;
for(i=0;i<(n*n);i++)
scanf("%d",&a[i]);
scanf("%d ",&t);
while(t--)
{
char q[8];
gets(q);
if(q[1]=='H')
{
for(i=0;i<(n*n);i++)
{
printf("%d ",a[i]);
j++;
if(j>=n)
{
printf("\n");
j=0;
}
}
}
else
{
int x=q[5]-'0',y=q[7]-'0',i1,i2;
for(i=0;i<(n*n);i++)
{
if(a[i]==x)
{i1=i;break;
}
}
for(i=0;i<(n*n);i++)
{
if(a[i]==y)
{i2=i;break;
}
}
a[i1]=y;
a[i2]=x;
}
}
}