| ||||||||||
| 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 | |||||||||
Re:为什么测试了各种数据都是对的,但是提交的时候却还是Wrong呢???求大神帮助呀In Reply To:为什么测试了各种数据都是对的,但是提交的时候却还是Wrong呢???求大神帮助呀 Posted by:zhjacm at 2013-04-09 23:22:04 > #include<iostream>
> using namespace std;
> int main()
> {
> char temp[100];
> int sum[100]={0},i,s,j,k=0,t=0;
> while(cin>>temp,temp[0]!='0')
> {
> int m[100]={0};
> for(i=0;temp[i]!='\0';i++);
> if(i>k)
> k=i;
> for(j=100-i,s=0;j<100;s++,j++)
> m[j]=temp[s]-48;
> for(j=99;j>99-k;j--)
> {
> sum[j]+=m[j];
> if(j==100-k)
> break;
> if(sum[j]>=10)
> {
> sum[j]-=10;
> sum[j-1]+=1;
> }
> }
> for(i=0;i<100;i++)
> temp[i]='\0';t++;
> }
>
> for(i=100-k;i<100;i++)
> cout<<sum[i];
> cout<<endl;
> return 0;
> }
>
> var sum:array[1..1000] of integer;
st:string;
i,l:integer;
begin
readln(st);
while st<>'0' do
begin
l:=length(st);
for i:=1 to l do
begin
inc(sum[i],ord(st[l+1-i])-ord('0'));
if sum[i]>=10 then
begin
inc(sum[i+1],sum[i] div 10);
sum[i]:=sum[i] mod 10;
end;
end;
readln(st);
end;
while sum[l]>0 do inc(l);
dec(l);
for i:=l downto 1 do write(sum[i]);
writeln;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator