Repeat Input Until Not Duplicate

Posted on 21.06.2010

0


program repeat_while_input_duplicate(Output);
uses crt;
var
   x : array[1..1000] of integer;
   i, n, tmp, j, cacah : integer;
begin
   clrscr;
   write(‘banyak data : ‘); readln(n);

{ .:: Input data ::. }
   for i:=1 to n do begin
      cacah:=0;
      repeat
         tmp:=random(100)+1;
         if cacah0 then cacah:=0;
         for j:=1 to i-1 do begin
            if x[j]=tmp then cacah:=cacah+1;
         end;
      until (cacah=0);
      x[i]:=tmp;
      write(x[i]:4,’ ‘);
      if (i mod 15=0) then writeln;
   end;
   writeln;
   writeln;

   readln;
end.

Posted in: Pascal Code