Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.12 KB | None | 0 0
  1. program szablon13;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. var
  9. n,i,a,suma,max,min,liczba:integer;
  10. srednia:real;
  11. spr:char;
  12. begin
  13. repeat
  14. writeln('Ile liczb chcesz podac? n>0'); readln(n);
  15. suma:=0;
  16.  
  17. if n <= 0 then
  18. begin
  19.      writeln('nie spelniono warunku');
  20.      readln;
  21. end
  22. else
  23. begin
  24.      for i:=1 to n do
  25.          begin
  26.               writeln('Podaj liczbe ',i,':');
  27.               readln(a);
  28.               if i=1 then
  29.               begin
  30.                    max:=a;
  31.               end;
  32.               suma:=suma+a;
  33.               srednia:=(srednia+a)/n;
  34.               if max < a then
  35.               begin
  36.                    max:=a;
  37.               end
  38.               else
  39.                    min:=a;
  40.  
  41.          end;
  42.  
  43. Writeln('Menu:');
  44.     Writeln('1) zobaczyc sume');
  45.     Writeln('2) zobaczyc srednia');
  46.     Writeln('3) zobaczyc max i min');
  47.     Writeln('Co robimy?: ');readln(liczba);
  48. case liczba of
  49.    1:writeln('Suma wynosi: ',suma);
  50.    2:writeln('Srednia wynosi: ',srednia:2:3);
  51.    3:writeln('Max: ',max,' Min: ',min);
  52.    end;
  53.  
  54.  end ;
  55. writeln;
  56. writeln('Raz jeszcze? t/n?: ');readln(spr);
  57. until spr = 'n';
  58.  
  59. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement