Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program operaciesosubormi;
- {$APPTYPE CONSOLE}
- uses SysUtils;
- var r,u:text;
- n,x,i,max,min,s,pc,udaj,pom:byte;
- c:array[1..255] of byte;
- begin
- { TODO -oUser -cConsole Main : Insert code here }
- assign(r,'randomcisla.txt'); assign(u,'usporiadanecisla.txt');
- write('Kolko cisiel chcete vygenerovat?: ');
- readln(n);
- write('Zadajte rozsah cisiel (0-x): ');
- readln(x);
- append(r);
- randomize;
- for i:=1 to n do
- begin
- c[i]:=random(x);
- writeln(r,c[i]);
- end;
- writeln(r);
- close(r);
- reset(r); append(u);
- max:=0;
- s:=0;
- pc:=0;
- min:=255;
- while not eof(r) do
- begin
- readln(r,udaj);
- write(udaj,' ');
- s:=s+udaj;
- pc:=pc+1;
- if udaj>max then max:=udaj;
- if udaj<min then min:=udaj;
- end;
- writeln;
- writeln('Priemer cisiel: ',s/pc:0:2);
- writeln('Maximalne cislo: ',max);
- writeln('Minimalne cislo: ',min);
- close(r); close(u);
- i:=0;
- while i<>n do
- begin
- inc(i);
- if c[i]>c[i+1] then
- begin
- pom:=c[i];
- c[i]:=c[i+1];
- c[i+1]:=pom;
- i:=0;
- end;
- end;
- append(u);
- for i:=1 to n do
- begin
- writeln(u,c[i]);
- end;
- writeln(u);
- close(u);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment