GamerSK

DU

Apr 19th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.77 KB | None | 0 0
  1. //napiste program ktorý vygeneruje n čisiel tak aby sa žiadne z nich neopakovalo
  2. program neopakujucesacisla;
  3. {$APPTYPE CONSOLE}
  4. uses SysUtils;
  5. var n,i,pc:byte;
  6.     c:array[1..255] of byte;
  7. begin
  8.   { TODO -oUser -cConsole Main : Insert code here }
  9.   write('Kolko cisiel chcete vygenerovat?: ');
  10.   readln(n);
  11.   randomize;
  12.   for i:=1 to n do c[i]:=random(100);
  13.   i:=0;
  14.   while i<>n do
  15.     begin
  16.       inc(i);
  17.       if c[i]>c[i+1] then
  18.         begin
  19.           pc:=c[i];
  20.           c[i]:=c[i+1];
  21.           c[i+1]:=pc;
  22.           i:=0;
  23.         end;
  24.     end;
  25.   for i:=2 to n+1 do write(c[i],' ');
  26.   writeln;
  27.   for i:=2 to n+1 do if c[i]<>c[i+1] then write(c[i],' ')
  28.     else begin
  29.           c[i]:=random(100);
  30.           write(c[i],' ');
  31.          end;
  32.   readln;
  33. end.
Advertisement
Add Comment
Please, Sign In to add comment