SHARE
TWEET

Redjanje Rijeci

a guest Mar 18th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program RedjanjeRijeci
  2. { Recenica se preuredjuje tako da se rijeci redjaju u opadajucem poretku po duzini }
  3.  
  4. type rijeci = array[1..20] of string;
  5.      duzine = array[1..20] of integer;
  6. var s1, s2 : string;
  7.     r : rijeci;
  8.     n, i, j, k : integer;
  9.     d : duzine;
  10.  
  11. procedure rastavi(s : string; var n : integer; var r : rijeci); // rastavlja recenicu s na niz rijeci r od n clanova
  12. begin
  13.     delete(s, length(s), 1);
  14.     s := s + ' '; n := 0;
  15.     while pos(' ', s) > 0 do begin
  16.         n := n + 1;
  17.         r[n] := copy(s, 1, pos(' ', s) - 1;
  18.         delete(s, 1, pos(' ', s));
  19.     end;
  20. end;
  21.  
  22. procedure sastavi(n : integer; r : rijeci; var s : string); // formira recenicu s od niza rijeci r od n clanova
  23. var i : integer;
  24. begin
  25.     s := '';
  26.     for i := 1 to n do s := s + [i] + ' ';
  27.     delete(s, length(s), 1);
  28.     s := s + '.';
  29. end;
  30.  
  31. procedure uredi(n : integer; var r : rijeci; var d : duzine); // uredjuje u opadajuci poredak niz rijeci po duzini
  32. var i, j, t : integer;
  33.     t1 : string;
  34. begin
  35.     for i := 1 to n - 1 do
  36.         for j := j + 1 to n do begin
  37.             if length(r[i]) < length(r[j]) then begin
  38.                 t1 := r[i]; r[i] := r[j]; r[j] := t1;
  39.             end;
  40.     end;
  41. end;
  42.  
  43. begin
  44.     write('Recenica: '); readln(s1);
  45.     rastavi(s1, n, r);
  46.     for i := 1 to n do writeln(r[i]);
  47.     uredi(n, r, d);
  48.     sastavi(n, r, s2);
  49.     writeln(s1); writeln(s2);
  50.    
  51.     readln;
  52. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top