| ||||||||||
| 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,也不知道是哪里错了,还请大神帮忙看看,是c语言写的,在线等!#include <stdio.h>
#include <string.h>
int main()
{
int s,n,i,j,cot,cnt,cut,tan,flag;
char tot[111][111],arr[101];
while(scanf("%d%s",&s,&arr))
{
cnt=strlen(arr);
for(cot=0; cot<cnt; cot++)
{
if(arr[cot]!=' ')
{
flag=cot;
break;
}
}
if(s==0&&arr[flag]=='0')
{
break;
}
cut=0;
for(cot=flag; cot<cnt; cot++)
{
tan=0;
if(arr[cot]=='1'||arr[cot]=='4')
{
for(j=cut; j<s+2+cut; j++)
{
tot[0][j]=' ';
}
}
else
{
for(j=cut; j<s+2+cut; j++)
{
if(j==cut||j==s+1+cut)
{
tot[0][j]=' ';
}
else
{
tot[0][j]='-';
}
}
}
tan++;
if(tan==1)
{
if(arr[cot]=='4'||arr[cot]=='8'||arr[cot]=='9'||arr[cot]=='0')
{
for(i=1; i<s+1; i++)
{
for(j=cut; j<s+2+cut; j++)
{
if(j==cut||j==s+1+cut)
{
tot[i][j]='|';
}
else
{
tot[i][j]=' ';
}
}
}
}
else if(arr[cot]=='5'||arr[cot]=='6')
{
for(i=1; i<s+1; i++)
{
for(j=cut; j<s+2+cut; j++)
{
if(j==cut)
{
tot[i][j]='|';
}
else
{
tot[i][j]=' ';
}
}
}
}
else
{
for(i=1; i<s+1; i++)
{
for(j=cut; j<s+2+cut; j++)
{
if(j==s+1+cut)
{
tot[i][j]='|';
}
else
{
tot[i][j]=' ';
}
}
}
}
}
tan++;
if(tan==2)
{
if(arr[cot]=='0'||arr[cot]=='1'||arr[cot]=='7')
{
for(j=cut; j<s+2+cut; j++)
{
tot[s+1][j]=' ';
}
}
else
{
for(j=cut; j<s+2+cut; j++)
{
if(j==cut||j==s+1+cut)
{
tot[s+1][j]=' ';
}
else
{
tot[s+1][j]='-';
}
}
}
}
tan++;
if(tan==3)
{
if(arr[cot]=='0'||arr[cot]=='6'||arr[cot]=='8')
{
for(i=s+2; i<2*s+2; i++)
{
for(j=cut; j<s+2+cut; j++)
{
if(j==cut||j==s+1+cut)
{
tot[i][j]='|';
}
else
{
tot[i][j]=' ';
}
}
}
}
else if(arr[cot]=='2')
{
for(i=s+2; i<2*s+2; i++)
{
for(j=cut; j<s+2+cut; j++)
{
if(j==cut)
{
tot[i][j]='|';
}
else
{
tot[i][j]=' ';
}
}
}
}
else
{
for(i=s+2; i<2*s+2; i++)
{
for(j=cut; j<s+2+cut; j++)
{
if(j==s+1+cut)
{
tot[i][j]='|';
}
else
{
tot[i][j]=' ';
}
}
}
}
}
tan++;
if(tan==4)
{
if(arr[cot]=='1'||arr[cot]=='4'||arr[cot]=='7')
{
for(j=cut; j<s+2+cut; j++)
{
tot[2*s+2][j]=' ';
}
}
else
{
for(j=cut; j<s+2+cut; j++)
{
if(j==cut||j==s+1+cut)
{
tot[2*s+2][j]=' ';
}
else
{
tot[2*s+2][j]='-';
}
}
}
}
cut+=s+3;
}
for(i=0; i<2*s+3; i++)
{
for(j=0; j<(cnt+1)*(s+2)+cnt; j++)
{
printf("%c",tot[i][j]);
}
printf("\n");
}
printf("\n");
memset(tot,0,sizeof(tot));
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator