| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
搞个屁啊,这题只是想说明用字符串来输入输出比数组快.#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator