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呢!!!!连n=0都考虑了阿!!没错啊!/*代码比较难看,见谅!*/ #include<iostream> #include<algorithm> using namespace std; char b[30][150]; int n,s; int l; void zero() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-'; for(i=1;i<2*s+2;i++) if(i!=1+s)b[i][l]='|',b[i][l+s+1]='|'; l+=s+2; } void one() { int i; l++; for(i=1;i<2*s+2;i++) if(i!=1+s) b[i][l+s+1]='|'; l+=s+2; } void two() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-'; for(i=1;i<1+s;i++) b[i][l+s+1]='|'; for(i=2+s;i<2*s+2;i++) if(i!=1+s)b[i][l]='|'; l+=s+2; } void three() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-'; for(i=1;i<2*s+2;i++) b[i][l+s+1]='|'; l+=s+2; } void four() { int i; l++; for(i=l+1;i<l+s+1;i++) b[1+s][i]='-'; for(i=1;i<2*s+2;i++) if(i!=1+s)b[i][l+s+1]='|'; for(i=1;i<1+s;i++) b[i][l]='|'; l+=s+2; } void five() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-'; for(i=1+1+s;i<2*s+2;i++) b[i][l+s+1]='|'; for(i=1;i<1+s;i++) b[i][l]='|'; l+=s+2; } void six() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-'; for(i=1+1+s;i<2*s+2;i++) b[i][l+s+1]='|'; for(i=1;i<2*s+2;i++) if(i!=1+s)b[i][l]='|'; l+=s+2; } void seven() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-'; for(i=1;i<2*s+2;i++) if(i!=1+s) b[i][l+s+1]='|'; l+=s+2; } void eight() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-'; for(i=1;i<2*s+2;i++) if(i!=1+s)b[i][l+s+1]='|'; for(i=1;i<2*s+2;i++) if(i!=1+s)b[i][l]='|'; l+=s+2; } void nine() { int i; l++; for(i=l+1;i<l+s+1;i++) b[0][i]='-',b[2*s+2][i]='-',b[1+s][i]='-'; for(i=1;i<2*s+2;i++) if(i!=1+s)b[i][l+s+1]='|'; for(i=1;i<1+s;i++) b[i][l]='|'; l+=s+2; } int main() { long num,m; int i,j; int aa[9]; //freopen("out.txt","w",stdout); while(1) { scanf("%ld%ld",&s,&num); if(!s) break; memset(b,' ',sizeof b); m=0; while(num>0) { aa[m++]=num%10; num/=10; } if(m==0) m=1,aa[0]=0; n=0; l=0; do { m--; switch(aa[m]) { case 0:zero();break; case 1:one();break; case 2:two();break; case 3:three();break; case 4:four();break; case 5:five();break; case 6:six();break; case 7:seven();break; case 8:eight();break; case 9:nine();break; } n++; }while(m>0); for(i=0;i<2*s+3;i++,putchar('\n')) for(j=1;j<=n*(s+2)+n-1;j++) putchar(b[i][j]); 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