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 |
求解各位大神~~~~~~为何wa?附代码#include<stdio.h> #include<string.h> void translate(char *str,int n){ char print[1000][1000]; int i,j,k; for(k = 0; k < (int )strlen(str); k++) { switch(str[k]) { case '1': for(i = 1; i <= n ; i++ ) { print[i][(n+3)*k+n+1] = '|';print[i+n+1][(n+3)*k+n+1] = '|'; }break; case '2': for(i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|'; }break; case '3': for(i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+n+1] = '|'; }break; case '4': for(i = 1; i <= n ; i++ ) { print[n+1][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|'; }break; case '5': for(i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|'; }break; case '6': for(i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[n+1+i][(n+3)*k+0] = '|'; }break; case '7': for(i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-'; print[i][(n+3)*k+n+1] = '|';print[i+n+1][(n+3)*k+n+1] = '|'; }break; case '8': for(i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[n+1+i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|'; }break; case '9': for(i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-';print[n+1][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|'; }break; case '0': for( i = 1; i <= n ; i++ ) { print[0][(n+3)*k+i] = '-';print[2*n+2][(n+3)*k+i] = '-'; print[n+1+i][(n+3)*k+n+1] = '|';print[i][(n+3)*k+0] = '|';print[n+1+i][(n+3)*k+0] = '|';print[i][(n+3)*k+n+1] = '|'; }break; } } for( i = 0; i < 2*n+3; i++ ) { for( j = 0; j < ((n+3)*k-1) ; j++ ) { if(print[i][j] != '|' && print[i][j] != '-') printf(" "); else printf("%c",print[i][j]); } printf("\n"); } } int main() { char a[15]; int n; while(scanf("%d %s",&n,a),a[0]!='0'||n) { if(n==0)printf("\n"); else { translate(a,n); printf("\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