Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位高手帮忙看看我错哪儿了??

Posted by shunfeng at 2008-07-22 15:06:42 on Problem 1102
#include<stdio.h>
#include<string.h>
int main()
{
    int s,i=0,j=0,num,p;
	char ch[30][90]={' '},n[20];
	scanf("%d %s",&s,&n);
	while(s!=0||strcmp(n,"0")!=0)
	{
		for(i=0;i<30;i++)
			for(j=0;j<90;j++)
				ch[i][j]=' ';
        i=0;j=0;
		num=strlen(n);
		for(i=0;i<num;i++)
		{
			switch(n[i]-'0')
			{
			   case 0:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[2*s+2][(s+3)*i+p]='-';
						  ch[p][(s+3)*i]='|';
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				     break;
			   case 1:for(p=1;p<=s;p++)
					  {
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				   break;
			   case 2:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[s+1][(s+3)*i+p]='-';
						  ch[2*s+2][(s+3)*i+p]='-';
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i]='|';
					  }
				   break;
			   case 3:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[s+1][(s+3)*i+p]='-';
						  ch[2*s+2][(s+3)*i+p]='-';
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				   break;
			   case 4:for(p=1;p<=s;p++)
					  {
						  ch[s+1][(s+3)*i+p]='-';
						  ch[p][(s+3)*i]='|';
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				   break;
			   case 5:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[s+1][(s+3)*i+p]='-';
						  ch[2*s+2][(s+3)*i+p]='-';
						  ch[p][(s+3)*i]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				   break;
			   case 6:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[s+1][(s+3)*i+p]='-';
						  ch[2*s+2][(s+3)*i+p]='-';
						  ch[p][(s+3)*i]='|';
						  ch[s+1+p][(s+3)*i]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				   break;
			   case 7:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				   break;
			   case 8:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[s+1][(s+3)*i+p]='-';
						  ch[2*s+2][(s+3)*i+p]='-';
						  ch[p][(s+3)*i]='|';
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				     break;
			   case 9:for(p=1;p<=s;p++)
					  {
						  ch[0][(s+3)*i+p]='-';
						  ch[s+1][(s+3)*i+p]='-';
						  ch[2*s+2][(s+3)*i+p]='-';
						  ch[p][(s+3)*i]='|';
						  ch[p][(s+3)*i+s+1]='|';
						  ch[s+1+p][(s+3)*i+s+1]='|';
					  }
				     break;
			}
		}
		for(i=0;i<2*s+3;i++)
		{
			for(j=0;j<num*(3+s)-1;j++)
				printf("%c",ch[i][j]);
			printf("\n");
		}
		printf("\n");
		scanf("%d %s",&s,n);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator