1.
var a,b:integer;
begin
a:=3;
b:=7;
a:=a-b;
b:=b+a;
a:=b-a;
writeln('a=',a);
writeln('b=',b);
end.
输出:a=7 b=3
2.
var
i, n, r, s, x: integer;
begin
readln(n);
for i:=1 to n do
begin
readln(x);
s:=0;
while x<>0 do
begin
r:=x mod 2;
if r=1 then s:=s+1;
x:=x div 2;
end;
writeln(s);
end;
end.
输入:
4
2
100
1000
66
输出:1 3 6 2
3.
var
s,s1:string;
i, a, b, k: integer;
begin
readln(s);
s1:='you';
k:=0;
a:=length(s);
b:=length(s1);
for i:=1 to a-b+1 do
if copy(s, i, b)=s1 then k:=k+1;
writeln(k);
end.
输入:It's easy. You get off the bus. Then you cross the road. You take the first road on the left. You walk for five minutes.
输出:1
4.
var x, y, z:integer;
procedure silly(x:integer;var y:integer);
begin
x:=7;y:=17;z:=18;
writeln(x, ' ',y,' ',z)
end;
begin
x:=1;y:=2;z=3;
silly(x,y);
writeln(x,' ',y,' ',z)
end;
输出:7 17 18 1 17 18
5.
var
n:longint;
procedure change(n:longint);
var
i,j:longint;
begin
if n=0 then exit;
i:=n mod 8;
j:=n div 8;
change(j);
writeln(i);
end;
begin
readln(n);
change(n);
end.
输入:2017
输出:3741