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 ice_43 at 2007-04-25 17:24:10 on Problem 1503
实在不知道少考虑什么了  哪位帮忙看看

#include<stdio.h>
#include<string.h>

int main()
{char num[110];
 int mid[110]={0},sum[110]={0};
 int i,length,n=0;
 while(scanf("%s",num),strcmp(num,"0"))
 {length=strlen(num);
  for(i=0;i<length;i++)
  mid[i]=num[length-1-i]-'0';
  for(i=0;i<110;i++)
  {sum[i]+=mid[i]+n;
   if(sum[i]>9)
	   {sum[i]-=10;
        n=1;
	   }
   else
	   n=0;
  }
  for(i=0;i<length;i++)
  {num[i]=' ';
   mid[i]=0;
  } 
 }
 
 for(i=110;;i--)
	 if(sum[i]!=0)
	 {length=i+1;
	  break;
	 }
 
 for(i=0;i<length;i++)
 printf("%d",sum[length-1-i]);
 printf("\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