GamerSK

Operácie so súbormi

Jun 7th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.87 KB | None | 0 0
  1. program operaciesosubormi;
  2. {$APPTYPE CONSOLE}
  3. uses SysUtils;
  4. var r,u:text;
  5.     n,x,i,max,min,s,pc,c:byte;
  6. begin
  7.   { TODO -oUser -cConsole Main : Insert code here }
  8.   assign(r,'randomcisla.txt'); assign(u,'usporiadanecisla.txt');
  9.   write('Kolko cisiel chcete vygenerovat?: ');
  10.   readln(n);
  11.   write('Zadajte rozsah cisiel (0-x): ');
  12.   readln(x);
  13.   append(r);
  14.   randomize;
  15.   for i:=1 to n do
  16.     begin
  17.       c:=random(x);
  18.       writeln(r,c);
  19.     end;
  20.   close(r);
  21.   reset(r);
  22.   max:=0;
  23.   s:=0;
  24.   pc:=0;
  25.   min:=255;
  26.   while not eof(r) do
  27.     begin
  28.       readln(r,c);
  29.       write(c,' ');
  30.       s:=s+c;
  31.       pc:=pc+1;
  32.       if c>max then max:=c;
  33.       if c<min then min:=c;
  34.     end;
  35.   close(r);
  36.   append(u);
  37.   writeln(u,'Priemer cisiel: ',s/pc:0:2);
  38.   writeln(u,'Maximalne cislo: ',max);
  39.   writeln(u,'Minimalne cislo: ',min);
  40.   writeln(u);
  41.   close(u);
  42. end.
Advertisement
Add Comment
Please, Sign In to add comment