#include<stdio.h>
#include<string.h>
int main()
{
char a[101];
int s[102] = {0}, i, j, k, n;
for(k=1;k<=100;k++)
{
scanf("%s", a);
if(a[0] == '0')
{
break;
}
n = strlen(a);
for(i=0,j=n-1;j>=0;i++,j--)
{
s[i] = s[i] + (a[j] - 48);
}
}
for(j=0;j<102;j++)
{
if(s[j]>=10)
{
s[j+1] = s[j+1] + s[j]/10;
s[j] = s[j]%10;
}
}
i = 101;
while(s[i] == 0 && i>= 0)
{
i--;
}
if(i == -1)
{
printf("0");
}
for( ;i>=0;i--)
{
printf("%d", s[i]);
}
printf("\n");
return 0;
}
#include<string.h>
int main()
{
char a[101];
int s[102] = {0}, i, j, k, n;
for(k=1;k<=100;k++)
{
scanf("%s", a);
if(a[0] == '0')
{
break;
}
n = strlen(a);
for(i=0,j=n-1;j>=0;i++,j--)
{
s[i] = s[i] + (a[j] - 48);
}
}
for(j=0;j<102;j++)
{
if(s[j]>=10)
{
s[j+1] = s[j+1] + s[j]/10;
s[j] = s[j]%10;
}
}
i = 101;
while(s[i] == 0 && i>= 0)
{
i--;
}
if(i == -1)
{
printf("0");
}
for( ;i>=0;i--)
{
printf("%d", s[i]);
}
printf("\n");
return 0;
}
Comments
Post a Comment