-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1503.cpp
More file actions
45 lines (42 loc) · 772 Bytes
/
1503.cpp
File metadata and controls
45 lines (42 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <string.h>
int ans[110];
void add(char a[101])
{
int len;
int ansi;
int t;
len=strlen(a)-1;
for(ansi=0;len>-1;--len,++ansi){
t=a[len]-'0';
ans[ansi]+=t;
if(ans[ansi]>=10){
ans[ansi+1]+=ans[ansi]/10;
ans[ansi]=ans[ansi]%10;
}
}
}
int main()
{
char input[110];
int i;
int len;
scanf("%s",input);
len=strlen(input);
while( !(1 == len && '0' == input[0])){
add(input);
scanf("%s",input);
len=strlen(input);
}
for(i=0;i<103;++i){
input[i]='0';
}
input[i]=0;
add(input);
for(i=109;ans[i] == 0;--i);
for(;i>-1;--i){
printf("%d",ans[i]);
}
printf("\n");
return 0;
}