1.
VAR i,a,b,c,d:integer;
f:array[0..3] of integer;
BEGIN
for i:=0 to 3 do
read(f[i]);
a:=f[0]+f[1]+f[2]+f[3];
a:=a div f[0];
b:=f[0]+f[2]+f[3];
b:=b div a;
c:=(b*f[1]+a) div f[2];
d:=f[(b div c) mod 4];
if (f[(a+b+c+d) mod 4]>f[2]) then
begin
a:=a+b;
writeln(a);
end else
begin
c:=c+d;
writeln(c);
end;
END.
输入:9 19 29 39
输出:23
2.
procedure foo(a,b,c:integer);
begin
if a>b then foo(c,a,b)
else writeln(a,',',b,',',c);
end;
var
a,b,c:integer;
begin
read(a,b,c);
foo(a,b,c);
end.
输入:3 1 2
输出:2,3,1
3.
type TT=array[0..20]of integer;
prodecure func(var ary:TT;n:integer);
var i,j,x:integer;
begin
i:=0;j:=n-1;
while i<j do begin
while (i<j) and (ary>0) do inc(i);
while (i<j) and (ary[j]<0) do dec(j);
if i<j then begin x:=ary;
ary:=ary[j];
ary[j]:=x;
inc(i);
dec(j);
end;
end;
end;
var
a:TT;
i,m:integer;
begin
m:=10;
for i:=0 to m-1 do
read(a);
func(a,m);
for i:=1 to m-1 do
write(a,' ');liyilong.net
writeln;
end.
输入:5 4 -6 -11 6 -59 22 -6 1 10
输出:5 4 10 1 6 22 -59 -6 -11 -6
4.
procedure solve(first:string;spos_f,epos_f:integer;mid:string;spos_m,epos_m:integer);
var i,root_m:integer;
begin
if spos_f > epos_f then exit;
for i:=spos_m to epos_m do
if first[spos_f]=mid[i] then begin
root_m:=i;
break;
end;
solve(first,spos_f+1,spos_f+(root_m-spos_m),mid,spos_m,root_m-1);
solve(first,spos_f+(root_m-spos_m)+1,epos_f,mid,root_m+1,epos_m);
write(first[spos_f]);
end;
var first,mid:string;
len:integer;
begin
readln(len);
readln(first);
readln(mid);
solve(first,1,len,mid,1,len);
writeln;
end.
输入:7
ABDCEGF
BDAGECF
输出:DBGEFCA