uva 227 模拟题
来源:互联网 发布:淘宝天猫内部优惠券网 编辑:程序博客网 时间:2024/06/04 19:30
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <cmath>#include <climits>#include <cstdlib>#include <ctime>#include <stack>using namespace std;//ios::sync_with_stdio(false);char a[10][10];char tma[10];int main(){int t = 1;//freopen("out.txt","w",stdout);//freopen("in.txt","r",stdin);while(1){gets(tma);if(strlen(tma) == 1 && tma[0] == 'Z'){break;}for(int i = 0;i < 5;i++){if(tma[i] == '\0')tma[i] = ' ';a[0][i] = tma[i];}for(int i = 1;i < 5;i++){gets(tma);for(int j =0 ;j < 5;j++){if(tma[j] == '\0')tma[j] = ' ';a[i][j] = tma[j];}}int sx,sy;for(int i = 0;i < 5;i++){for(int j = 0;j < 5;j++){if(a[i][j] == ' '){sx = i;sy = j;}}}char op;int flag = 0;while(op = getchar(),op != '0'){int nx = sx ,ny= sy;switch (op){case 'A':{nx --;break;}case 'B':{nx ++;break;}case 'R':{ny ++;break;}case 'L':{ny --;break;}default:{continue;}}if(flag) continue;if(nx < 0 || nx >= 5 || ny < 0 || ny >= 5){flag = 1;continue;}else{swap(a[sx][sy],a[nx][ny]);sx = nx;sy = ny;}}if(t != 1)printf("\n");printf("Puzzle #%d:\n",t++);if(flag){printf("This puzzle has no final configuration.\n");}elsefor(int i = 0;i < 5;i++){for(int j = 0;j < 5;j++){if(j!= 0)printf(" ");printf("%c",a[i][j]);}printf("\n");}getchar(); }return 0;}长期因为在输出最后的提示串的时候发现自己少复制了一个‘.’已经不是一次啦!真是错都不知道自己是哪里错了!水!!!
0 0
- uva 227 模拟题
- UVa 227 模拟
- uva 227--模拟
- UVA 10196 模拟题。。
- uva 10881 模拟题
- UVA 220 Othello 模拟题
- uva 1589 Xiangqi 模拟题
- UVa 227 Puzzle (紫书上的题,模拟)
- UVa 227 Puzzle 【数组和字符串】【模拟】
- UVA 573 Steps 简单模拟题
- (1.1.8)UVA 10120 Gift?!(模拟题)
- UVA 575(模拟大水题)
- UVA-133 双向链表模拟题
- UVa 127 线性表模拟题
- UVA 621 Secret Research 水题模拟
- UVa 1587 有趣的模拟题
- UVa 100 简单模拟
- UVa 602 简单模拟
- ARM开发板移植android4.0流程
- tcp4---(总结一下)---what.if.process.crash.and.reboot
- json与java实体类的相互转换
- HDU 1754 I Hate It
- 关于平台常用技术资料
- uva 227 模拟题
- PHP内置方法小记
- 黑马程序员:iOS基础——个人笔记(四)
- Google protocol buffer使用笔记
- 模拟文件系统
- Android 中一个animation实例只能被一个View对象引用
- 毕业半年转Android的找工作和学习之路----持续更新中。。。。
- Android多线程分析之四:MessageQueue的实现
- Struts2中EL表达式取值