1.
program test1;
var
a,b,c,d,e,ans: integer;
begin
readln(a,b,c);
d:=a+b;
e:=abs(b-c);
ans:=trunc((d+e)/(c-a));
writeln(ans);
end.
输入:1 2 5
输出:1
2.
program test2;
var
n,m:longint;
Begin
Readln(n,m);
n:=n mod 7;
m:=m mod 5;
If n>m then writeln(n)
else writeln(m)
End.
输入:2014 2015
输出:5
3.
program test3;
var
n,x,i,temp,j,count:longint;
begin
readln(n,x);
for i:=1 to n do
begin
temp:=i;
while temp>0 do
begin
j:=temp mod 10;
temp:=temp div 10;
if j=x then inc(count);
end;
end;
writeln(count);
end.
输入:100 5
输出:20
4.
program test4;
var
i,j,k,n:integer;
a:array[1..100] of boolean;
begin
read(n);
for i:=1 to n do a[i]:=true;
for i:=1 to n do
begin
j:=i;
while j<=n do
begin
a[j]:=not(a[j]);
j:=j+i;
end;
end;
for i:=1 to n do
if a[i]=true then write('0',' ')
else write('1',' ');
end.
输入:8
输出:1 0 0 1 0 0 0 0
5.
program test5;
type
arr=array[1..8] of integer;
var
a:arr; i,n:integer;
procedure select(var b:arr; var n:integer);
var
i,j:integer;
begin
i:=0;
for j:=1 to n do
if b[j] mod 3=0 then
begin
i:=i+1;
b[i]:=b[j];
end;
n:=i;
end;
begin
n:=8;
for i:=1 to n do read(a[i]);
readln;
select(a,n);
for i:=1 to n do write(a[i]:3);
writeln;
end.
输入:8 151 9 7 233 68 514 12
输出:9 12