Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

谁帮我看一下

Posted by My_loves at 2005-08-12 14:05:27 on Problem 2562
program p2562;
 var a,b:string;
     max:integer;
     out:integer;

 procedure init;
  var s:string;
      i:integer;
      ch:char;
  begin
   readln(s);
   if s='0 0' then halt;
   i:=pos(' ',s);
   a:=copy(s,1,i-1);
   b:=copy(s,i+1,length(s)-i);
   for i:=1 to length(a) div 2 do
    begin
     ch:=a[i];
     a[i]:=a[length(a)-i+1];
     a[length(a)-i+1]:=ch;
    end;
   for i:=1 to length(b) div 2 do
    begin
     ch:=b[i];
     b[i]:=b[length(b)-i+1];
     b[length(b)-i+1]:=ch;
    end;
   if length(a)>length(b) then max:=length(a)
                          else max:=length(b);
  end;

 procedure main;
  var i,j,k,add:integer;
  begin
   add:=0;
   for i:=1 to max do
    begin
     j:=ord(a[i])-48;
     k:=ord(b[i])-48;
     if j<0 then j:=0;
     if k<0 then k:=0;
     if j+k+add>=10 then begin inc(out); add:=1 end
                    else add:=0;
    end;
  end;

 begin
  repeat
   a:='';
   b:='';
   out:=0;
   init;
   main;
   if out=0 then write('No')
            else write(out);
   writeln(' carry operation.');
  until false;
 end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator