| ||||||||||
| 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 | |||||||||
Re:搞个屁啊,这题只是想说明用字符串来输入输出比数组快.In Reply To:搞个屁啊,这题只是想说明用字符串来输入输出比数组快. Posted by:donkeyinacm at 2010-03-31 16:50:28 > #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