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

为什么会output exceed limit 呢?好象就我的会,别人的都没有出现过这个问题

Posted by 13791234567 at 2008-12-21 10:27:16 on Problem 1102
# include<stdio.h>
int code[10][7]={
	1,1,1,0,1,1,1,
	0,0,1,0,0,1,0,
	1,0,1,1,1,0,1,
	1,0,1,1,0,1,1,
	0,1,1,1,0,1,0,
	1,1,0,1,0,1,1,
	1,1,0,1,1,1,1,
	1,0,1,0,0,1,0,
	1,1,1,1,1,1,1,
	1,1,1,1,0,1,1};
int size,lon,thenumber;
int number[9];




int muti(int i)
{
	int j=0,k=1;
	for(;j<i;j++)
		k*=10;
	return k;
}
void input()
{
     int p=0,t=7,temp;
     scanf("%d %ld",&size,&thenumber);getchar();
	 //printf("the size is %d,thenumber is %d",size,thenumber);

	 if(thenumber>0)
     while(1)
	 {
		 if((thenumber-muti(t))>=0)
			 break;
		 t--;
	 }
     temp=thenumber;

     while(t>=0)
     {
		 number[p]=temp/muti(t);
		 //printf("the number[%d] is %d\n",p,number[p]);
		 temp=temp-number[p]*muti(t);
		 t--;
		 p++;
	 }
     number[p+1]=-1;
     lon=p;
}

void display()
{
     int i,j,k;
	 //printf("the first row:");
     for(i=0;i<lon;i++)                               //the first row
	 {
		 printf(" ");
		 if(code[number[i]][0]==1)
		 {
			 for(j=0;j<size;j++)
				 printf("-");
		 }
		 else
		 {
			 	 for(j=0;j<size;j++)
				 printf(" ");
		 }
         printf(" ");
	 }
	 printf("\n");
	 //printf(" after the first row \n");
     //printf("the s rows :");
	 for(i=0;i<size;i++)                             //the s rows;
	 {         
		 for(j=0;j<lon;j++)
		 {
			 if(code[number[j]][1]==1)
				 printf("|");
			 else
				 printf(" ");
			 for(k=0;k<size;k++)
				 printf(" ");
			 if(code[number[j]][2]==1)
				 printf("|");
			 else
				 printf(" ");

		 }
		 printf("\n");
	 }
     //printf("the middle row :");
     for(i=0;i<lon;i++)                           //the middle rows;
     {
		 printf(" ");
		 if(code[number[i]][3]==1)
		 {
			 for(j=0;j<size;j++)
				 printf("-");
		 }
		 else
		 {
			 	 for(j=0;j<size;j++)
				 printf(" ");
		 }
         printf(" ");
	 }
	 printf("\n");
     //printf("the s row:");
     for(i=0;i<size;i++)                             //the s rows;
	 {         
		 for(j=0;j<lon;j++)
		 {
			 if(code[number[j]][4]==1)
				 printf("|");
			 else
				 printf(" ");
			 for(k=0;k<size;k++)
				 printf(" ");
			 if(code[number[j]][5]==1)
				 printf("|");
			 else
				 printf(" ");

		 }
		 printf("\n");
	 }
     //printf("the last row:");
     for(i=0;i<lon;i++)                           //the last row
     {
		 printf(" ");
		 if(code[number[i]][6]==1)
		 {
			 for(j=0;j<size;j++)
				 printf("-");
		 }
		 else
		 {
			 	 for(j=0;j<size;j++)
				 printf(" ");
		 }
         printf(" ");
	 }
	 printf("\n");
}

int main()
{
	while(1)
	{
		input();
	    //printf("after input\n");
		//printf("size is %d,lon is %d\n",size,lon);
        if(size==0&&thenumber==0)
			break;
		display();
		printf("\n");
	}
	return 1;
}

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