⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tju1127.pas

📁 同济大学ACM题库TJU1127的题解代码.
💻 PAS
字号:
const sss='0123456789'; 
var 
 n,i,l,at,shu,yu,tt,ft:integer; 
 s,temp,tempx:string; 
 bb:boolean; 
begin 
 readln(n); 
 for i:=1 to n do begin 
   readln(s); 
   write(s,' '); 
   if s<>'1' then begin 
   repeat 
     l:=length(s); 
     if (s[l]='0')or(s[l]='2')or(s[l]='4')or(s[l]='6')or(s[l]='8') then begin 
       temp:=''; at:=0; yu:=0; 
       repeat 
         inc(at); 
         shu:=pos(s[at],sss)-1; 
         if shu>=2 then begin 
           shu:=shu+yu*10; 
           yu:=shu mod 2; 
           shu:=shu div 2; 
           temp:=temp+sss[shu+1]; 
         end else begin 
           if at=1 then begin 
             yu:=pos(s[at],sss)-1; 
             inc(at); 
           end; 
           shu:=pos(s[at],sss)-1; 
           shu:=shu+yu*10; 
           yu:=shu mod 2; 
           shu:=shu div 2; 
           temp:=temp+sss[shu+1]; 
         end; 
       until (at=l)or(at=l+1); 
       write(temp,' '); 
       s:=temp; 
     end else begin 
       temp:=''; at:=length(s)+1; yu:=0; 
       repeat 
         dec(at); 
         if at=0 then shu:=0 else shu:=pos(s[at],sss)-1; 
         shu:=shu*3+yu; 
         yu:=shu div 10; 
         shu:=(shu mod 10); 
         temp:=temp+sss[shu+1]; 
       until at=0; 
       tempx:=''; 
       tt:=length(temp); 
       ft:=0; 
       while temp[tt]='0' do begin 
         tt:=tt-1; 
         ft:=ft+1; 
       end; 
       delete(temp,tt+1,ft); 
       for tt:=length(temp) downto 1 do tempx:=tempx+temp[tt]; 
       tt:=length(tempx)+1; 
       if tempx='9' then begin s:='10';write(s,' ') end else begin 
       if tempx[length(tempx)]<'9' then begin 
         tempx[length(tempx)]:=chr(ord(tempx[length(tempx)])+1) 
                                   end else begin 
                                     ft:=length(tempx); 
                                     tempx[ft]:='0'; 
                                     repeat 
                                       ft:=ft-1; 
                                       if tempx[ft]='9' then tempx[ft]:='0' 
                                                        else begin 
                                                          tempx[ft]:=chr(ord(tempx[ft])+1); 
                                                          break; 
                                                        end; 
                                     until (tempx[ft-1]<='8'); 
                                     bb:=false; 
                                     for tt:=1 to length(tempx) do if tempx[tt]<>'0' then begin 
                                       bb:=true; 
                                       break; 
                                     end; 
                                     if not bb then tempx:='1'+tempx; 
                                     if tempx[ft]='0' then tempx[ft-1]:=chr(ord(tempx[ft-1])+1); 
                                   end; 
       write(tempx,' '); 
       s:=tempx; 
       end; 
     end; 
   until s='1'; 
 end; 
   writeln; 
 end; 
end. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -