| ||||||||||
| 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 | |||||||||
????????????/怎么回事????这样都WA?(tzj115)In Reply To:Why Posted by:luxuejuncarl at 2007-06-06 01:59:48 # include <stdio.h>
# include <string.h>
# include <iostream.h>
char s[105];
int d[105];
void qu_0(char s[])
{
int i=0;
int l=strlen(s);
while(s[i]=='0')
i++;
for(int j=0;j<l-i;j++)
{
s[j]=s[j+i];
}
s[j]='\0';
//return l-i;
}
void add(int d[],char s[])
{
int len=strlen(s);
s=strrev(s);
int c=0;
for(int i=0;i<len;i++)
{
d[i]+=c+(s[i]-'0');
c=d[i]/10;
d[i]%=10;
}
d[i]=c;
}
int main()
{
memset(d,0,105*sizeof(int));
cin>>s;
qu_0(s);//////////////////////////////
while(strcmp(s,"0"))
{
add(d,s);
cin>>s;
qu_0(s);//////////////////////////
}
int j=104;
while(d[j]==0)
j--;
for(int m=j;m>=0;m--)
cout<<d[m];
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator