几道简单的PASCAL题,麻烦帮忙一下,拜托了,急用

2024-12-22 15:53:25
推荐回答(3个)
回答1:

3.
var a:array[1..1000] of 0..1;
b:array[1..1000] of integer;
k,n,i:integer;
begin
readln(n);
for i:=1 to n do begin read(b[i]);a[b[i]]:=1;end;
for i:=1 to 1000 do k:=k+a[i];
writeln(k);
for i:=1 to 1000 do if (a[i]=1) then write(i,' ');
end.
4.
var a:array[1..10] of 0..300;
n:99..121;
i,z:integer;
begin
z:=0;
for i:=1 to 10 do read(a[i]);
readln(n);
for i:=1 to 10 do
if (n+30>=a[i]) then inc(z);
writeln(z);
end.
5.
var a:array[1..7,1..2] of 0..10;
i,j,max,x:integer;
begin
max:=0;x:=0;
for i:=1 to 7 do
begin
for j:=1 to 2 do
read(a[i,j]);
if (a[i,1]+a[i,2]>max) then begin max:=a[i,1]+a[i,2];x:=i;end;
end;
writeln(x);
end.

回答2:

这是奥赛的初赛题!!!!!
3.
var a:array[1..1000] of 0..1;
b:array[1..1000] of integer;
k,n,i:integer;
begin
readln(n);
for i:=1 to n do begin read(b[i]);a[b[i]]:=1;end;
for i:=1 to 1000 do k:=k+a[i];
writeln(k);
for i:=1 to 1000 do if (a[i]=1) then write(i,' ');
end.
4.
var a:array[1..10] of 0..300;
n:99..121;
i,z:integer;
begin
z:=0;
for i:=1 to 10 do read(a[i]);
readln(n);
for i:=1 to 10 do
if (n+30>=a[i]) then inc(z);
writeln(z);
end.
5.
var a:array[1..7,1..2] of 0..10;
i,j,max,x:integer;
begin
max:=0;x:=0;
for i:=1 to 7 do
begin
for j:=1 to 2 do
read(a[i,j]);
if (a[i,1]+a[i,2]>max) then begin max:=a[i,1]+a[i,2];x:=i;end;
end;
writeln(x);
end.

回答3:

这是奥赛的初赛题