#1337: 我错在哪里?


liyuqin33 (...)

學校 : 飞厦中学
編號 : 5191
來源 : [61.141.0.208]
最後登入時間 :
2010-07-08 09:34:16
c014. 10035 - Primary Arithmetic -- UVa10035 | From: [61.141.0.211] | 發表日期 : 2009-02-07 11:31

var a,x,z,p:string;  
 b,c,d,t,l,i,g,h,q,s:integer;  
begin 
  while a<>'0 0' do 
    begin 
      d:=0;  
      t:=0;  
      a:='';  
      x:='';  
      z:='';  
      readln(a);  
      if a='0 0'then break;  
      l:=length(a);  
      s:=0;  
      for i:=l downto 1 do 
      begin 
        s:=s+1;  
        if a[i]=' ' then break else insert(a[i],x,s);  
      end;  
      s:=0;  
      g:=length(x);  
      s:=0;  
      for i:=l-g-1 downto 1 do 
      begin 
        s:=s+1;  
        insert(a[i],z,s);  
      end;  
      h:=length(z);  
      if h<g then q:=g else q:=h;  
      for i:=1 to q do 
        begin 
          val(x[i],b);  
          val(z[i],c);  
          if (b+c+d)>9 then t:=t+1;  
          d:=(b+c+d)div 10;  
        end;  
      if t=0 then write('No') else write(t);  
      write(' carry operation');  
      if t>=2 then writeln('s.') else writeln('.')  
    end;  
end.   
ZeroJudge Forum