UVa 227 - Puzzle
来源:互联网 发布:ubuntu 拨号 编辑:程序博客网 时间:2024/05/02 02:25
做了两天了,死活不AC,后来发现是判断边界出了问题,改了下后就AC了。
#include<stdio.h>#include<string.h>char s[10][10],str[10000];int main(){ int i,j,time=1; while(1) { memset(s,0,sizeof(s)); memset(str,0,sizeof(str)); int m=0,n=0,k; int q=1; char temp; for(i=0; i<5; i++) for(j=0;j<6;j++) { s[i][j]=getchar(); if(s[i][j]=='Z') return 0; } for(i=0;; i++) { scanf("%c",&str[i]); if(str[i]=='0') break; } k=strlen(str); for(i=0; i<5; i++) for(j=0; j<5; j++) { if(s[i][j]==' ') { m=i; n=j; break; } } for(i=0; i<k; i++) { if(str[i]=='0') break; if(str[i]=='A'&&m) { s[m][n]=s[m-1][n]; s[m-1][n]=' '; --m; q=1; continue; } else if(str[i]=='B'&&m!=4) { s[m][n]=s[m+1][n]; s[m+1][n]=' '; ++m; q=1; continue; } else if(str[i]=='R'&&n!=4) { s[m][n]=s[m][n+1]; s[m][n+1]=' '; ++n; q=1; continue; } else if(str[i]=='L'&&n) { s[m][n]=s[m][n-1]; s[m][n-1]=' '; --n; q=1; continue; } else if(str[i]=='\n') continue; else { q=0; break; } } if(time!=1) printf("\n"); printf("Puzzle #%d:\n",time); if(q==1) { for(i=0; i<5; i++) { for(j=0; j<5; j++) { if(j!=4) printf("%c ",s[i][j]); else printf("%c",s[i][j]); } printf("\n"); } } else { printf("This puzzle has no final configuration.\n"); } if(scanf("%c",&s[0][0])=='Z') break; time++; } return 0;}
0 0
- UVa 227 - Puzzle
- UVa 227 - Puzzle
- Uva-227-Puzzle
- UVa 227 Puzzle
- UVA - 227 Puzzle
- Uva-227 - Puzzle-AC
- UVa 227 - Puzzle
- UVa-227 - Puzzle
- 【Uva 227】 Puzzle
- UVa 227 - Puzzle
- UVa 227 Puzzle
- UVA - 227 Puzzle
- Uva - 227 - Puzzle
- UVA - 227 Puzzle
- UVa 227 Puzzle
- UVA 227 Puzzle
- UVa 227 - Puzzle
- UVa 227 Puzzle
- 2-07. 素因子分解(20)
- UVA - 507 - Jill Rides Again (dp最大子段和)
- 841
- 最近情况
- myeclipse设置注释
- UVa 227 - Puzzle
- java.lang.NoClassDefFoundError: org/springframework/web/context/request/asynWeb...
- 求一组整数的排列组合
- C语言第一个周六
- Linux Apache 给 awstats 创建 访问密码
- input value="值栈的值"
- 快排模板
- vs2008 对话框中插入自制的ActiveX的方法
- LLVM中TableGen工具的使用