Posted on 2008-10-14 23:54
Hero 阅读(73)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 // 1048 C++ Accepted 0.281 7 981 KB
2
3 #include <stdio.h>
4 #include <stdlib.h>
5
6 const int size = 1100000 ;
7
8 int data1[size], data2[size] ;
9
10 int inn ;
11
12 int main()
13 {
14 while( scanf( "%d", &inn ) != EOF )
15 {
16 for( int i=1; i<=inn; i++ )
17 {
18 scanf( "%d %d", &data1[i], &data2[i] ) ;
19 }
20
21 int i ; int carry = 0 ;
22 for( i=inn; i>=1; i-- )
23 {
24 data1[i] = (data1[i]+data2[i]+carry) ;
25 carry = data1[i] / 10 ;
26 data1[i] = data1[i] % 10 ;
27 }
28 data1[i] = carry ;
29
30 //for( i=0; i<=inn&&0==data1[i]; i++ ) ;
31
32 for( i=1; i<=inn; i++ )
33 printf( "%d", data1[i] ) ;
34
35 printf( "\n" ) ;
36
37 }
38
39 return 0 ;
40 }
41