键位移动有的时候会动有的时候不会动
include <stdio.h>#include <string.h>
int main()
{
int row=2,line=3;
char s[6][6]={"TRGSJ","XDOKI","M VLN","WPABE","UQHCF"};
int n;
char ch;
int i,j;
while(1)
{
scanf("%d",&n);
switch(n)
{
case 1:
if(row!=1)
{
ch=s[line-1][row-1];
s[line-1][row-1]=s[line-1][row-2];
s[line-1][row-2]=ch;
row--;
}
break;
case 5:
if(line!=1)
{
ch=s[line-1][row-1];
s[line-1][row-1]=s[line-2][row-1];
s[line-2][row-1]=ch;
line++;
}
break;
case 2:
if(line!=5)
{
ch=s[line-1][row-1];
s[line-1][row-1]=s[line][row-1];
s[line][row-1]=ch;
line--;
}
break;
case 3:
if(row!=5)
{
ch=s[line-1][row-1];
s[line-1][row-1]=s[line-1][row];
s[line-1][row]=ch;
row++;
}
break;
default:
break;
}
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
printf("%c",s[i][j]);
}
printf("\n");
}
}
return 0;
}