GamerSK

Matica - Min a Max

May 4th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.27 KB | None | 0 0
  1. //Napiste program ktorý si vypýta celé čisla matice RxS vypíše ju na obrazovku a
  2. //vypíše informáciu aká je max hodnota a na akej pozícii sa nachádza.
  3. //min
  4. program minmaxmatica;
  5. {$APPTYPE CONSOLE}
  6. uses SysUtils;
  7. var r,s,i,j,max,min:byte;
  8.     c:array[1..255,1..255] of byte;
  9.     maxs,mins:string;
  10. begin
  11.   { TODO -oUser -cConsole Main : Insert code here }
  12.   write('Zadajte pocet riadkov: ');
  13.   readln(r);
  14.   write('Zadajte pocet stlpcov: ');
  15.   readln(s);
  16.   max:=0; min:=255;
  17.   for i:=1 to r do
  18.     begin
  19.       for j:=1 to s do
  20.         begin
  21.           write('Zadajte cislo pre suradnicu (',i,',',j,'): ');
  22.           readln(c[i,j]);
  23.           if c[i,j]>max then
  24.             begin
  25.               max:=c[i,j];
  26.               maxs:=inttostr(i)+','+inttostr(j);
  27.             end;
  28.           if c[i,j]<min then
  29.             begin
  30.               min:=c[i,j];
  31.               mins:=inttostr(i)+','+inttostr(j);
  32.             end;
  33.         end;
  34.     end;
  35.   for i:=1 to r do
  36.     begin
  37.       for j:=1 to s do
  38.         begin
  39.           write(c[i,j]:5);
  40.         end;
  41.       writeln;
  42.     end;
  43.   write('Maximalne cislo je: ',max);
  44.   writeln('  Nachadza sa na suradnici: ',maxs);
  45.   write('Minimalne cislo je: ',min);
  46.   writeln('  Nachadza sa na suradnici: ',mins);
  47.   readln;
  48. end.
Advertisement
Add Comment
Please, Sign In to add comment