UVa227
来源:互联网 发布:手机练钢琴软件 编辑:程序博客网 时间:2024/05/22 03:06
= =史上无敌大坑题,居然最后一行不能换行,不能有尾随空格
#pragma warning(disable:4996)#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<vector>#include<algorithm>#include<iostream>#include<time.h>#include<set>#include<sstream>#include<functional>#include<cassert>#include<list>#include<iterator>#include<utility>#include <stdexcept> #include <sstream>#include <fstream> #include<unordered_map>#include<unordered_set>#include<ctype.h>#include<map>using namespace std;using namespace std::placeholders;char s[5][5];int x, y;int flag;void Move(char tmp){ switch (tmp) { case 'A': { if (x == 0) { flag = 0; return; } char temp; temp = s[x - 1][y]; s[x - 1][y] = s[x][y]; s[x][y] = temp; x--; break; } case 'B': { if (x == 4) { flag = 0; return; } char temp; temp = s[x + 1][y]; s[x + 1][y] = s[x][y]; s[x][y] = temp; x++; break; } case 'L': { if (y == 0) { flag = 0; return; } char temp; temp = s[x][y - 1]; s[x][y - 1] = s[x][y]; s[x][y] = temp; y--; break; } case 'R': { if (y == 4) { flag = 0; return; } char temp; temp = s[x][y + 1]; s[x][y + 1] = s[x][y]; s[x][y] = temp; y++; break; } }}int main(){ int cas = 1; while (scanf("%c", &s[0][0])) { if (s[0][0] == '\n') scanf("%c", &s[0][0]); if (s[0][0] == 'Z') return 0; for (int i = 1; i < 5; i++) scanf("%c", &s[0][i]); getchar(); int i, j; for (i = 1; i < 5; i++) { for (j = 0; j < 5; j++) scanf("%c", &s[i][j]); if (s[i][4] != '\n') getchar(); } for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { if (s[i][j] == '\n') s[i][j] = ' '; if (s[i][j] == ' ') { x = i; y = j; } } } char temp; if (cas != 1) printf("\n"); cout << "Puzzle #" << cas++ << ":" << endl; flag = 1; while ((temp = getchar()) != '0') { if (temp == '\n' || temp == '\r') continue; Move(temp); } if (!flag) { printf("This puzzle has no final configuration.\n"); } else { for (int i = 0; i < 5; i++) { printf("%c %c %c %c %c\n", s[i][0], s[i][1], s[i][2], s[i][3],s[i][4]); } } } return 0;}
0 0
- UVA227
- uva227
- UVA227
- Uva227
- UVa227
- Uva227
- UVa227
- UVa227
- UVA227
- UVA227
- Uva227 - Puzzle
- uva227 谜题
- Uva227.Puzzle
- UVA227-Puzzle
- UVa227 Puzzle
- uva227 - Puzzle
- Puzzle,UVa227
- UVA227--谜题
- Androd安全——反编译技术完全解析
- 机器视觉开源代码集合
- android中自己画一个按钮,和自己设置一个框框
- Java中Atomic包的原理和分析
- HDU ACM 11 2017 字符串统计
- UVa227
- 使用ExpandableTextView遇到的坑
- Unity ugui拼界面规则
- 174. Dungeon Game
- 使用MVC模型的用户登录及注册(登录部分)
- Jquery中的on()使用理解,无法使用on方法
- 第4课 Android开发工具——Gradle知识汇总
- codeforces 369C
- RecyclerView初步试用(一)