――阅读程序,写出程序正确的运行结果

 

1.PROGRAM NOI__002;
    VAR I,J,L,N,K,S,T: INTEGER;
      B: ARRAY[1..10] OF 0..9;
   BEGIN
     READLN(L,N);S:=L;  K:=1;  T:=L;
     WHILE S     BEGIN K:=K+1;  T:=T*L;   S:=S+T  END;
     S:=S-T; N:=N-S-1;
     FOR I:=1 TO 10 DO  B[I]:=0;
     J:=11;
     WHILE N>0 DO
     BEGIN  J:=J-1;  B[J]:=N MOD L;  N:=N DIV L  END;
     FOR I:=10-K+1 TO 10 DO WRITE(CHR(ORD('A')+B[I]));
   END
  输入:4  167
  输出:

 

2.PROGRAM NOI__004;
    VAR I,J,J1,J2,P,Q: INTEGER;
       P1: BOOLEAN;
       B,C: ARRAY[1..100] OF INTEGER;
    BEGIN
      READLN(Q,P);  J:=1;  P1:=TRUE;  B[J]:=Q;  J1:=0;
      WHILE (Q>0 AND P1 DO
      BEGIN
       J1:=J1+1; C[J1]:=Q*10 DIV P; Q:=Q*10-C[J1]*P;
       IF Q>Q THEN BEGIN
              J2:=1;
              WHILE (B[J2]<>Q) AND (J2<=J) DO  J2:=J2+1;
              IF B[J2]=Q THEN
               BEGIN
                P1:=FALSE;  WRITE('0.');
                FOR I:=1 TO J2-1 DO  WRITE(C[I]:1);
                WRITE('{'};
                FOR I:=J2 TO J1 DO  WRITE(C[I]:1);
                WRITELN(')')
               END
          ELSE  BEGIN  J:=J+1;  B[J]:=Q  END
       END
      END;
      IF Q=0 THEN BEGIN
             WRITE('0.');
             FOR I:=1 TO J1 DO  WRITE(C[I]:1);
             WRITELN
            END;
      READLN
   END.  
   输入  ①1  8  输出
   输入  ②2  7  输出

 

3program exp1;

var i,j,k,n,,L0,L1,LK:Integer;

a :array [0..20] of integer;

begin

readln(n,k);

for i:=0 to n-1 do a[i]:=i+1;

a[n]:=a[n-1];L0:=n-1; Lk:=n-1;

for I:=1 to n-1 do

begin

L1:=L0-k; if (l1<0) then L1:=L1+n;

If (l1=Lk) then

begin

           A[L0]:=a[n]; Lk:=Lk-1; a[n]:=a[Lk]; l0:=lk

        End

Else

Begin

     A[l0]:=a[l1];l0:=l1;

End;

End;

A[L0]:=a[n];

For I:=0 to n-1 do write(a[I]:40);

Writeln;

End.

输入:10   4

输出:

 

4program exp2;

var n,jr,jw,jb:integer;

ch1:char;

ch:array[1..20]d char;

begin

readln(n);

for i:=1 to n do read(ch[i]):

jr:=1;jwz=n;jb:=n;:

while (jr<=jw)do

begin

if(ch[jw]='R') then

begin

ch1:=Ch[jr];Ch[jr]:=ch[jw];ch[jw]:=ch1:jr:=jr+13

end

else if ch[jw]='W' then jw:=jw-1

else begin

ch1:=ch[jw];ch[jw]:=ch[jb];ch[jb]:=ch1;jw:=jw-1;jb:=jb-1;

end

end;

for i:=1 to n do write(ch[i]);

writeln;

end.

输入: 10

RBRBWWRBBR

输出:

 

 

5Program exp3;

Var I,j,p,n,q,s:integer;

a :array[1..20]of integer;

begin

readln(p,n,q);j :=21;

while (n>0)do

begin

j:=j-1;a[j]:=n mod 10;n:=n div 10;

end;

s:=0;

for i:=j t0 20 do s:=s*p+a[i];

writeln(s);

j :=21;

while (s>O)do

begin

 j:=j-1;a[j]:=s mod q;s:=s div q;

end;

for i:=j to 20 do write(a[i]);

readln;

end.

输入: 7 3051 8

输出: