1) var a:array[1..20] of integer; index, Min,count, i, n:integer; begin Readln(n); Min:= 81;index:=-1; For i:= 1 to n do begin a[i]:= random(96) - 15; Write(a[i], ' '); if Min = a[i] then count:= count+1; if Min > a[i] then begin Min:=a[i]; index:=i; count:=1; end; end; Writeln; Writeln('Min = ', Min); Writeln('Минимумов: ', count, ' их сумма равна ', count*Min); for i:= n downto 2 do if (a[i] < 0) and (a[i-1] < 0) then begin Write('Номера соседних отрицательных эл-в -> '); Writeln(i-1, ' ', i); break; end; end.
Пример: 20 59 -3 44 -15 60 -3 70 -15 -10 1 -1 -2 21 23 -5 24 45 -10 0 48 Min = -15 Минимумов: 2 их сумма равна -30 Номера соседних отрицательных эл-в -> 11 12
2)
var a,b:array[1..200] of integer; i, n,cnt, j, Max:integer; begin Readln(n); Read(a[1]);Max:=a[1];cnt:=1; For i:= 2 to n do begin Read(a[i]); if a[i] = max then cnt:= cnt+1; if a[i] > max then begin max:=a[i]; cnt:=1; end; end; j:=1; for i:=1 to n do if a[i] < Max then begin b[j]:=a[i]; j:= j+1; end; for i:= j to n do b[i]:=Max; for i:=1 to n do Write(b[i], ' '); end.
Пример: 6 1 5 3 2 5 0 1 3 2 0 5 5
type Info = record name:string; unpl:integer;//unemployment end;
var a:array[1..40] of Info; tmp:Info; i, j:integer; begin For i:= 1 to 40 do begin Readln(a[i].name); Readln(a[i].unpl); end; For i:= 1 to 40 do for j:= i to 40 do if a[i].unpl > a[j].unpl then begin tmp.name:= a[i].name; tmp.unpl:= a[i].unpl; a[i].name:=a[j].name; a[i].unpl:=a[j].unpl; a[j].name:=tmp.name; a[j].unpl:=tmp.unpl; end; Writeln('три неблагополучных района:') Writeln(a[40].name); Writeln(a[39].name); Writeln(a[38].name); Writeln('три наиболее благополучных'); Writeln(a[1].name); Writeln(a[2].name); Writeln(a[3].name); end.
var a,b,c, max, min:real; begin Readln(a,b,c); if (a > b) and (a > c) then Max:= a; if (c > b) and (c > a) then Max:= c; if (b > a) and (b > c) then Max:= b;
if (a < b) and (a < c) then Min:= a; if (c < b) and (c < a) then Min:= c; if (b < a) and (b < c) then Min:= b;
if (a <> min) and (a <> max) then writeln(a); if (b <> min) and (b <> max) then writeln(b); if (c <> min) and (c <> max) then writeln(c); end.
var
a:array[1..20] of integer;
index, Min,count, i, n:integer;
begin
Readln(n);
Min:= 81;index:=-1;
For i:= 1 to n do
begin
a[i]:= random(96) - 15;
Write(a[i], ' ');
if Min = a[i] then
count:= count+1;
if Min > a[i] then begin
Min:=a[i];
index:=i;
count:=1;
end;
end;
Writeln;
Writeln('Min = ', Min);
Writeln('Минимумов: ', count, ' их сумма равна ', count*Min);
for i:= n downto 2 do
if (a[i] < 0) and (a[i-1] < 0) then
begin
Write('Номера соседних отрицательных эл-в -> ');
Writeln(i-1, ' ', i);
break;
end;
end.
Пример:
20
59 -3 44 -15 60 -3 70 -15 -10 1 -1 -2 21 23 -5 24 45 -10 0 48
Min = -15
Минимумов: 2 их сумма равна -30
Номера соседних отрицательных эл-в -> 11 12
2)
var
a,b:array[1..200] of integer;
i, n,cnt, j, Max:integer;
begin
Readln(n);
Read(a[1]);Max:=a[1];cnt:=1;
For i:= 2 to n do
begin
Read(a[i]);
if a[i] = max then
cnt:= cnt+1;
if a[i] > max then
begin
max:=a[i];
cnt:=1;
end;
end;
j:=1;
for i:=1 to n do
if a[i] < Max then
begin
b[j]:=a[i];
j:= j+1;
end;
for i:= j to n do
b[i]:=Max;
for i:=1 to n do
Write(b[i], ' ');
end.
Пример:
6
1 5 3 2 5 0
1 3 2 0 5 5
type Info = record
name:string;
unpl:integer;//unemployment
end;
var
a:array[1..40] of Info;
tmp:Info;
i, j:integer;
begin
For i:= 1 to 40 do
begin
Readln(a[i].name);
Readln(a[i].unpl);
end;
For i:= 1 to 40 do
for j:= i to 40 do
if a[i].unpl > a[j].unpl then
begin
tmp.name:= a[i].name;
tmp.unpl:= a[i].unpl;
a[i].name:=a[j].name;
a[i].unpl:=a[j].unpl;
a[j].name:=tmp.name;
a[j].unpl:=tmp.unpl;
end;
Writeln('три неблагополучных района:')
Writeln(a[40].name);
Writeln(a[39].name);
Writeln(a[38].name);
Writeln('три наиболее благополучных');
Writeln(a[1].name);
Writeln(a[2].name);
Writeln(a[3].name);
end.
Формат Ввода:
Название района
Безработица
var
a,b,c, max, min:real;
begin
Readln(a,b,c);
if (a > b) and (a > c) then Max:= a;
if (c > b) and (c > a) then Max:= c;
if (b > a) and (b > c) then Max:= b;
if (a < b) and (a < c) then Min:= a;
if (c < b) and (c < a) then Min:= c;
if (b < a) and (b < c) then Min:= b;
if (a <> min) and (a <> max) then writeln(a);
if (b <> min) and (b <> max) then writeln(b);
if (c <> min) and (c <> max) then writeln(c);
end.
Пример:
-9 3 6
3