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

怎么想都不会有错,可就是WA!

Posted by e_e_e at 2006-07-17 13:33:26 on Problem 1503
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

char a[103];
int c[103];
int main()
{
	int i,j;
	memset(c,0,103*sizeof(int));
	while(gets(a))
	{
		if(a[0]=='0')
			break;
		j=102;
		for(i=strlen(a)-1;i>=0;i--)	
		{
			c[j]+=(a[i]-'0');
			if(c[j]>=10)
			{
				c[j-1]+=c[j]/10;
				c[j]%=10;
			}
			j--;
		}
		memset(a,0,103*sizeof(char));
	}
	for(i=0;i<103 && (!c[i]);i++);
	for(j=i;j<103;j++)
			printf("%d",c[j]);	
	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