| ||||||||||
| 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 | |||||||||
给个PASCAL的代码var
a,b,c:array [1..255] of byte;
s:string;
i,j,k,n,t:integer;
begin
readln(n);
for i:=1 to n do
begin
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
readln(s);
for j:=1 to pos(' ',s)-1 do a[j]:=ord(s[j])-48;
for j:=pos(' ',s)+1 to length(s) do
b[j-pos(' ',s)]:=ord(s[j])-48;
if (pos(' ',s)-1)>(length(s)-pos(' ',s)) then k:=(pos(' ',s)-1)
else k:=(length(s)-pos(' ',s));
for j:=1 to k do c[j]:=a[j]+b[j];
for j:=1 to k-1 do if c[j]>9 then begin c[j]:=c[j]-10;inc(c[j+1]) end;
if c[k]>9 then begin c[k]:=c[k]-10;inc(k);c[k]:=1; end;
t:=1;
for j:=1 to k do if c[j]=0 then inc(t)
else break;
for j:=t to k do write(c[j]);
writeln;
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator