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<stdlib.h> #include<string.h> char top[100],mih[100],mid[100],mil[100],bot[100]; void display(int d,int s) { int i,ii; char num[10]; _itoa(d,num,10); top[0]=mih[0]=mid[0]=mil[0]=bot[0]='\0'; for(ii=0;num[ii]!='\0';ii++) { char stop[13],smih[13],smid[13],smil[13],sbot[13]; stop[s+2]=smih[s+2]=smid[s+2]=smil[s+2]=sbot[s+2]='\0'; switch(num[ii]) { case '1': for(i=0;i<=s;i++) stop[i]=smih[i]=smid[i]=smil[i]=sbot[i]=' '; stop[i]=smid[i]=sbot[i]=' '; smih[i]=smil[i]='|'; break; case '2': stop[0]=smih[0]=smid[0]=sbot[0]=' '; smil[0]='|'; for(i=1;i<=s;i++) { stop[i]=smid[i]=sbot[i]='-'; smih[i]=smil[i]=' '; } stop[i]=smid[i]=smil[i]=sbot[i]=' '; smih[i]='|'; break; case '3': stop[0]=smih[0]=smid[0]=smil[0]=sbot[0]=' '; for(i=1;i<=s;i++) { stop[i]=smid[i]=sbot[i]='-'; smih[i]=smil[i]=' '; } stop[i]=smid[i]=sbot[i]=' '; smih[i]=smil[i]='|'; break; case '4': stop[0]=smid[0]=smil[0]=sbot[0]=' '; smih[0]='|'; for(i=1;i<=s;i++) { smid[i]='-'; stop[i]=smih[i]=smil[i]=sbot[i]=' '; } stop[i]=smid[i]=sbot[i]=' '; smih[i]=smil[i]='|'; break; case '5': stop[0]=smid[0]=smil[0]=sbot[0]=' '; smih[0]='|'; for(i=1;i<=s;i++) { stop[i]=smid[i]=sbot[i]='-'; smih[i]=smil[i]=' '; } stop[i]=smih[i]=smid[i]=sbot[i]=' '; smil[i]='|'; break; case '6': stop[0]=smid[0]=sbot[0]=' '; smih[0]=smil[0]='|'; for(i=1;i<=s;i++) { stop[i]=smid[i]=sbot[i]='-'; smih[i]=smil[i]=' '; } stop[i]=smih[i]=smid[i]=sbot[i]=' '; smil[i]='|'; break; case '7': stop[0]=smih[0]=smid[0]=smil[0]=sbot[0]=' '; stop[0]=smid[0]=sbot[0]=' '; for(i=1;i<=s;i++) { stop[i]='-'; smih[i]=smid[i]=smil[i]=sbot[i]=' '; } stop[i]=smid[i]=sbot[i]=' '; smih[i]=smil[i]='|'; break; case '8': stop[0]=smid[0]=sbot[0]=' '; smih[0]=smil[0]='|'; for(i=1;i<=s;i++) { stop[i]=smid[i]=sbot[i]='-'; smih[i]=smil[i]=' '; } stop[i]=smid[i]=sbot[i]=' '; smih[i]=smil[i]='|'; break; case '9': stop[0]=smid[0]=smil[0]=sbot[0]=' '; smih[0]='|'; for(i=1;i<=s;i++) { stop[i]=smid[i]=sbot[i]='-'; smih[i]=smil[i]=' '; } stop[i]=smid[i]=sbot[i]=' '; smih[i]=smil[i]='|'; break; case '0': stop[0]=smid[0]=sbot[0]=' '; smih[0]=smil[0]='|'; for(i=1;i<=s;i++) { stop[i]=sbot[i]='-'; smih[i]=smid[i]=smil[i]=' '; } stop[i]=smid[i]=sbot[i]=' '; smih[i]=smil[i]='|'; break; } strcat(top,stop); strcat(mih,smih); strcat(mid,smid); strcat(mil,smil); strcat(bot,sbot); if(num[ii+1]!='\0'){ strcat(top," "); strcat(mih," "); strcat(mid," "); strcat(mil," "); strcat(bot," "); } } printf("%s\b\n",top); for(i=0;i<s;i++) printf("%s\b\n",mih); printf("%s\b\n",mid); for(i=0;i<s;i++) printf("%s\b\n",mil); printf("%s\b\n",bot); for(int j=0;j<strlen(top);j++)printf("%c",' '); } int main() { int count=-1,i; int s[10000],n[10000]; do { count++; scanf("%d%d",&s[count],&n[count]); }while(s[count]!=0); for(i=0;i<count-1;i++) { display(n[i],s[i]); printf("\n"); } if(count!=0) display(n[count-1],s[count-1]); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator