#include<iostream>
#include <cstdio>
#include<algorithm>
using namespace std
;
char cell
[5][5] = { {'T','R','G','S','J'},
{'x','D','O','K','I'},
{'M',' ','V','L','N'},
{'W','P','A','B','E'},
{'U','Q','H','C','F'}
};
int main(){
char c
;
int i
,j
;
i
= 2;
j
= 1;
while((c
= getchar()) !=EOF){
if(c
== '0'){
for(i
= 0;i
< 5;i
++){
for(j
= 0;j
< 5;j
++){
printf("%c ",cell
[i
][j
]);
}
printf("\n");
}
break;
}else if(c
== 'A'){
swap(cell
[i
][j
],cell
[i
- 1][j
]);
i
--;
}else if(c
== 'B'){
swap(cell
[i
][j
],cell
[i
+ 1][j
]);
i
++;
}else if(c
== 'L'){
swap(cell
[i
][j
],cell
[i
][j
- 1]);
j
--;
}else if(c
== 'R'){
swap(cell
[i
][j
],cell
[i
][j
+ 1]);
j
++;
}else{
printf("This puzzle has no final configuration\n");
}
}
system("pause");
return 0;
}
转载请注明原文地址:https://tech.qufami.com/read-7551.html