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 LVans at 2008-08-11 11:36:46 on Problem 2602
#include <iostream>

using namespace std;

int main()
{
//freopen("code.txt","r",stdin);

int n,i,j,f=0,temp,num=0;
cin>>n;

int *a=new int[n+1];
int *b=new int[n+1];
int *sum=new int[n+1];

for(i=n-1; i>=0; i--)
cin>>a[i]>>b[i];

a[n]=b[n]=0;

for(j=0; j<=n; j++)
{
temp= a[j]+ b[j]+ f;
sum[j]= temp>=10 ? temp-10 : temp;
f= temp>=10 ? 1 : 0;
}


for(i=n; i>=0; i--)
//num=(num+sum[i])*10;
num=num*10+sum[i];

cout<<num<<endl;
delete [] sum;
delete [] a;
delete [] b;
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