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 donkeyinacm at 2010-03-31 16:50:28 on Problem 2602
#include <iostream>
using namespace std;
#define MAXN 1000005
int n;
char a[MAXN],b[MAXN],c[MAXN];

void add()
{
	int i,s=0;
	for(i=n-1;i>=0;i--)
	{
		s+=a[i]-'0'+b[i]-'0';
		c[i]=s%10+'0';
		s/=10;
	}
}

int main()
{
	//freopen("c:/a.txt","r",stdin);
	int i;
	while(scanf("%d\n",&n)!=EOF)
	{
	for(i=0;i<n;i++)
	{
    a[i]=getchar();
	getchar();
	b[i]=getchar();
	getchar();
	}
    add();
	printf("%s\n",c);
	}
	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