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

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

Posted by benbenbeibei at 2006-03-16 22:10:29
In Reply To:Re:请各位大牛帮我看看1503题的代码,测试好象没什么问题但总是WRONG ANSWER!!!谢谢^_^ Posted by:fjctlzy at 2006-03-16 21:00:18
不好意思,您能不能再解释一下,为什么以前的那个不行呢? 我觉得sum[k]好象不会>19  再次感谢!!!
> #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+1]=sum[k+1]+sum[k]/10;//change the code here
> 		sum[k]=sum[k]%10;//change the code here
> 			}
> 		}
> 		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