Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
POJ能过,但是Uva却WA,各位大神帮我看看啊~~~~这个题POJ能过,但在Uva 706 提交的时候却WA了,这是我的代码: #include <stdio.h> #include <string.h> int main() { int s,n; int i,j,k; int len; char a[15]; while(scanf("%d",&s)) { getchar(); gets(a); len=strlen(a); if(s == 0 && a[0] == '0' && len == 1) break; //1、输出第1行 for(j=0; j<len; j++) { if(a[j] == '0' || a[j] == '2' || a[j] == '3' || a[j] == '5' || a[j] == '6' || a[j] == '7' || a[j] == '8' || a[j] == '9') { printf(" "); for(k=1; k<=s; k++) { printf("-"); } printf(" "); } else if(a[j] == '1' || a[j] == '4') { for(k=1; k<=s+2; k++) { printf(" "); } } if(a[j+1] != '\0') printf(" "); //隔开列 } printf("\n"); //2、输出第2~s+1行 (1~s) for(i=1; i<=s; i++) { for(j=0; j<len; j++) { if(a[j] == '1' || a[j] == '2' || a[j] == '3' || a[j] == '7') { for(k=1; k<=s+1; k++) { printf(" "); } printf("|"); } else if(a[j] == '5' || a[j] == '6') { printf("|"); for(k=1; k<=s+1; k++) { printf(" "); } } else if(a[j] == '4' || a[j] == '8' || a[j] == '9' || a[j] == '0') { printf("|"); for(k=1; k<=s; k++) { printf(" "); } printf("|"); } if(a[j+1] != '\0') printf(" "); //隔开列 } printf("\n"); } //3、输出第s+2行 for(j=0; j<len; j++) { if(a[j] == '2' || a[j] == '3' || a[j] == '4' || a[j] == '5' || a[j] == '6' || a[j] == '8' || a[j] == '9') { printf(" "); for(k=1; k<=s; k++) { printf("-"); } printf(" "); } else if(a[j] == '0' || a[j] == '1' || a[j] == '7') { for(k=1; k<=s+2; k++) { printf(" "); } } if(a[j+1] != '\0') printf(" "); //隔开列 } printf("\n"); //4、输出第s+3行~2s+2行(1~s) for(i=1; i<=s; i++) { for(j=0; j<len; j++) { if(a[j] == '1' || a[j] == '3' || a[j] == '4' || a[j] == '5' || a[j] == '7' || a[j] == '9') { for(k=1; k<=s+1; k++) { printf(" "); } printf("|"); } else if(a[j] == '0' || a[j] == '8' || a[j] == '6') { printf("|"); for(k=1; k<=s; k++) { printf(" "); } printf("|"); } else if(a[j] == '2') //必须写成 else if(a[j] == 2)不能写成else,因为如果输入的是异常情况,就不能输出 { printf("|"); for(k=1; k<=s+1; k++) { printf(" "); } } if(a[j+1] != '\0') printf(" "); //隔开列 } printf("\n"); } //5、输出2s+3行 for(j=0; j<len; j++) { if(a[j] == '0' || a[j] == '2' || a[j] == '3' || a[j] == '5' || a[j] == '6' || a[j] == '8' || a[j] == '9') { printf(" "); for(k=1; k<=s; k++) { printf("-"); } printf(" "); } else if(a[j] == '1' || a[j] == '4' || a[j] == '7') { for(k=1; k<=s+2; k++) { printf(" "); } } if(a[j+1] != '\0') printf(" "); //隔开列 } printf("\n\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator