各位大虾帮我看一看这道程序哪里错了,zojacm1292integerinquiry
OneofthefirstusersofBIT'snewsupercomputerwasChipDiller.Heextendedhisexplorationofpowersof3togofrom0to333andheexploredtakingvarioussumsofthosenumbers.
``Thissupercomputerisgreat,''remarkedChip.``IonlywishTimothywereheretoseetheseresults.''(Chipmovedtoanewapartment,onceonebecameavailableonthethirdflooroftheLemonSkyapartmentsonThirdStreet.)
Input
Theinputwillconsistofatmost100linesoftext,eachofwhichcontainsasingleVeryLongInteger.EachVeryLongIntegerwillbe100orfewercharactersinlength,andwillonlycontaindigits(noVeryLongIntegerwillbenegative).
Thefinalinputlinewillcontainasinglezeroonalinebyitself.
Output
YourprogramshouldoutputthesumoftheVeryLongIntegersgivenintheinput.
Thisproblemcontainsmultipletestcases!
ThefirstlineofamultipleinputisanintegerN,thenablanklinefollowedbyNinputblocks.Eachinputblockisintheformatindicatedintheproblemdescription.Thereisablanklinebetweeninputblocks.
TheoutputformatconsistsofNoutputblocks.Thereisablanklinebetweenoutputblocks.
SampleInput
1
123456789012345678901234567890
123456789012345678901234567890
123456789012345678901234567890
SampleOutput
370370367037037036703703703670
#include
#include
intmain()
{
chara[200]={0};
inti,m,n,k,j,sum[200]={0};
scanf("%d",&k);
while(k--)
{
n=0;
while(scanf("%s",a)&&a[0]!='0')
{
m=strlen(a);
n=n>m?n:m;
for(i=0;i=0)
sum[i]+=(a[m-i-1]-'0');
sum[i+1]+=sum[i]/10;
sum[i]%=10;
}
if(sum[n]!=0)
n++;
}
for(i=n-1;i>=0;i--)
printf("%d",sum[i]);
if(k)
printf("nn");
memset(sum,0,sizeof(sum));
}
return0;
}