GamerSK

Prečítanie údajov zo súbora v riadku

Jun 12th, 2017
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.67 KB | None | 0 0
  1. //Program vygeneruje n cisiel a zapise ich do jednoho riadku a cisla budu oddelene medzerou
  2. program ncisiel;
  3. {$APPTYPE CONSOLE}
  4. uses SysUtils;
  5. var r:text;
  6.     n,i,c:byte;
  7. begin
  8.   { TODO -oUser -cConsole Main : Insert code here }
  9.   assign(r,'cisla.txt');
  10.   write('Kolko chcete vygenerovat cisiel?: ');
  11.   readln(n);
  12.   randomize;
  13.   rewrite(r);
  14.   randomize;
  15.   for i:=1 to n do
  16.     begin
  17.       c:=random(100);
  18.       if i<>n then write(r,c,' ') else write(r,c);
  19.     end;
  20.   close(r);
  21.   reset(r);
  22.   while not eof(r) do
  23.     begin
  24.       while not eoln(r) do
  25.         begin
  26.           read(r,c);
  27.           writeln(c);
  28.         end;
  29.     end;
  30.   close(r);
  31.   readln;
  32. end.
Advertisement
Add Comment
Please, Sign In to add comment