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 azazasyb at 2009-09-18 18:35:20 on Problem 1503
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int arr[110] = { 0 };
	string str;
	int i;
	int max = 0;

	while ( true )
	{
		cin>>str;
		if ( str[0] == '0' )
			break;
		if ( max < str.length() )
			max = str.length();

		for ( i=str.length()-1; i>=0; i-- )
		{
			arr[str.length()-1-i] += static_cast<int>((str[i])-'0');
		}

	}
	for ( i=0; i<max-1; i++ )
	{
		arr[i+1] += arr[i]/10;
		arr[i] %= 10;
	}
	for ( i=max-1; i>=0; i-- )
		cout<<arr[i];
	cout<<endl;


	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