Redaciple00

Модернизация определения инверсий

Sep 17th, 2019
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.38 KB | None | 0 0
  1. var
  2.   x, k, i, j, n:integer;
  3.   a: array [1..75] of integer;
  4. begin
  5.   for i:=1 to 75 do
  6.   begin
  7.     readln (x);
  8.     a[i]:=x;
  9.   end;
  10.   k:=0;
  11.   write ('S=');
  12.   for i:=1 to 74 do
  13.   begin
  14.     for j:=i+1 to 75 do
  15.     begin
  16.       if (a[i] > a[j])
  17.       then begin
  18.       k:=k+1;
  19.       n:=n+1 end;    
  20.     end;
  21.     write(n, '+');
  22.       n:=0;
  23.   end;
  24.   write ('= ', k);
  25. end.
Advertisement
Add Comment
Please, Sign In to add comment