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

请各位大牛帮我看看1503题的代码,测试好象没什么问题但总是WRONG ANSWER!!!谢谢^_^

Posted by benbenbeibei at 2006-03-16 20:52:06
#include<iostream.h>
#include<string.h>
char VeryLongInteger[101];
char temp[101];
int sum[103];
void main()
{
	int i,j,k,m;
	cin>>temp;
	while(strcmp(temp,"0"))
	{
		for(i=0;temp[i]!='\0';i++);
		for(j=i-1;j>=0;j--)
			VeryLongInteger[i-1-j]=temp[j];
		for(k=0;k<i;k++)
			sum[k]+=VeryLongInteger[k]-'0';
		for(k=0;k<103;k++)
		{
			if(sum[k]>9)
			{
				sum[k]-=10;
				sum[k+1]++;
			}
		}
		for(k=102;k>=0;k--)
		{
			if(sum[k]!=0)
				break;
		}
		cin>>temp;
	}
	for(m=k;m>=0;m--)
		cout<<sum[m];
	cout<<endl;
}









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