Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program project1;
- var
- tablica : array [0..7] of integer;
- i, i2 : integer;
- plik : TextFile;
- function srednia(tablica : array of integer) : double;
- begin
- srednia :=0;
- i2:=0;
- for i:=0 to 7 do
- if (tablica[i] mod 2) = 0 then
- begin
- srednia := srednia + tablica[i];
- i2:=i2+1;
- end;
- srednia := srednia/i2;
- end;
- procedure zblizona(tablica : array of integer);
- var
- pomoc, min, max :integer;
- begin
- min := tablica[0];
- max := tablica[0];
- pomoc := round(srednia(tablica));
- for i:=0 to 7 do
- begin
- if (tablica[i] < min) then min := tablica[i];
- if (tablica[i] > max) then max := tablica[i];
- end;
- for i:=0 to 7 do
- begin
- if ((tablica[i] >=min) and (tablica[i] <pomoc)) then min :=tablica[i];
- if ((tablica[i] <= max) and (tablica[i] > pomoc )) then max := tablica[i];
- end;
- if (max-pomoc) > (pomoc-min) then writeln(#10#13,'Najblizsz: ', min)
- else writeln(#10#13,'Najblizsza: ', max);
- end;
- begin
- for i:=0 to 7 do
- readln(tablica[i]);
- for i:=0 to 7 do
- writeln(#10#13,'[',i,']', tablica[i]);
- writeln('Srednia: ', srednia(tablica));
- zblizona(tablica);
- AssignFile(plik, 'nowy1.txt');
- Rewrite(plik);
- for i:=0 to 7 do
- writeln(plik, tablica[i],#10#13,#10#13);
- CloseFile(plik);
- readln();
- end.
Add Comment
Please, Sign In to add comment