1.
Var
al,a2,a3,x:integer;
procedure swap (var a,b:integer);
Var
t:integer;
begin
var
t:integer;
begin
t:=a;
a:=b;
b:=t;
end;
begin
readln(al,a2,a3);
if al >a2 then
swap(a 1,a2);
if a2>a3 then
swap (a2,a3);
if al>a2 then
swap(a1,a2);
readlnl(x);
if x<a2 then
if x<al then
writeln(x, ‘ ‘,a1,’ ‘,a2,’ ‘,a3)
e1se
writeln(a1, ’ ‘,x,’ ‘,a2,’ ‘,a3)
else
if x<a3 then
writeln(al,’ ‘,a2,’ ‘,x,’ ‘,a3)
else
writeln(al,’ ‘, a2, ‘ ‘, a3, ‘ ‘.x);
end.
输入:
91 2 20
77
输出:2 20 77 91
2.
Var
n,m,i:integer;
function rsum(j:integer):integer;
var
sum:integer;
begin
sum:=0;
while j <> 0 do
begin
sum:=sum * 10 +(j mod 10);
j:=j div 10;
end;
rsum:=sum;
end;
begin
readln(n,m);
for i:=n to m do
if i=rsum(i)
then write(I, ‘ ‘);
end.
输入:90 120
输出:99 101 111
3.
Var
S:string;
i:integer;
m1,m2:char;
begin
readln(s);
n1:= ‘ ‘;
m2:=’ ‘;
for i:=1 to length(s) do
if s[i] > m1 then
begin
m2:=m1;
m1:=s[i];
end
else if s[i] > m2 then
m2:=s[i];
writeln(ord(m1), ‘ ‘, ord(m2));
end.
输入:Expo 2010 Shanchai China
输出:120 112
4.
const
NUM=5;
Var
n:integer;
function r(n:integer}:intecer;
Var
i:integer;
begin
if n< = NUM then
begin
r:=n;
exit;
end;
for i:=1 to NUM d0
if r(n-i) < 0 then
begin
r:=i;
exit;
end;
begin
readln(n);
writeln(r(n));
end.
(1)
输入: 7
输入: 16
输出:1|4