Михайлович_гергиевич315
?>

Дан массив чисел, проверить для каждого числа сколько существует в списке числе меньше данного числа и давить в другой список. Вернуть массив. Example 1: Input: nums = [8, 1, 2, 2, 3] Output: [4, 0, 1, 1, 3] Explanation: For nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3 For nums[1]=1 does not exist any smaller number than it. For nums[2]=2 there exist one smaller number than it (1). For nums[3]=2 there exist one smaller number than it (1). For nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).

Информатика

Ответы

Татьяна902
Const
  n = 10;
var
  a: array[1..n] of integer;
  i, j, t: integer;
 
begin
  Randomize;
  Writeln('Исходный массив');
  for i := 1 to n do
  begin
    a[i] := Random(16)-10;
    Write(a[i]:4)
  end;
  Writeln;
  for i := 1 to n-1 do
    for j := 1 to n-i do
      if a[j] > a[j+1] then
      begin t := a[j]; a[j] := a[j+1]; a[j+1] := t end;
  Writeln('Отсортированный по возрастанию массив');
  for i := 1 to n do Write(a[i]:4);
  Writeln
end.

Тестовое решение:
Исходный массив
 -10  -9   2  -3  -6 -10  -2   5   4   0
Отсортированный по возрастанию массив
 -10 -10  -9  -6  -3  -2   0   2   4   5
R7981827791127
Const
  m = 3;
  n = 4;
var
  a: array[1..m, 1..n] of integer;
  b: array[1..m] of real;
  i, j, k: integer;
  min:real;

begin
  Writeln('Введите оценки студентов');
  for i := 1 to m do
  begin
    b[i]:=0;
    for j := 1 to n do
    begin Read(a[i,j]); b[i]:=b[i]+a[i,j] end;
    b[i]:=b[i]/n
  end;
  k:=1; min:=b[1];
  for i:=2 to 3 do
    if min>b[i] then begin min:=b[i]; k:=i end;
  Writeln('Студент номер ',k,' имеет минимальный cредний ',min:5:2)
end.

Тестовое решение:
Введите оценки студентов
5 4 4 3
3 5 3 4
4 5 4 5
Студент номер 2 имеет минимальный cредний   3.75

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Дан массив чисел, проверить для каждого числа сколько существует в списке числе меньше данного числа и давить в другой список. Вернуть массив. Example 1: Input: nums = [8, 1, 2, 2, 3] Output: [4, 0, 1, 1, 3] Explanation: For nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3 For nums[1]=1 does not exist any smaller number than it. For nums[2]=2 there exist one smaller number than it (1). For nums[3]=2 there exist one smaller number than it (1). For nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

myataplatinumb348
Voronov434
Vrezh
delta88
vvk2008
ea-office
bezzfamilny631
apetrov54
Vos-sv
Tatyana1374
smartschoolfili6
dg9792794674
tatk00
Tatyana Anton1475
Dmitrievich1871
▲