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; 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator