По разделам

 

Решение задачи Matrix 74


Дана матрица размера M × N. Элемент матрицы называется ее локальным минимумом, если он меньше всех окружающих его элементов. Заменить все локальные минимумы данной матрицы на нули. При решении допускается использовать вспомогательную матрицу.

Код (Pascal)

program Matrix74;
type
  matrix = array [1..10,1..10] of integer;
 
var
  a:matrix;
  K, M, N, i, j:Integer;
 
Function CheckMatrixLocMin(var mat:matrix; X,Y:Integer):Boolean;
 Begin
  CheckMatrixLocMin:=true;
  if x>1 then
   if mat[x,y]>=mat[x-1,y] then CheckMatrixLocMin:=False;
  if x=mat[x+1,y] then CheckMatrixLocMin:=False;
  if y>1 then
   if mat[x,y]>=mat[x,y-1] then CheckMatrixLocMin:=False;
  if y=mat[x,y+1] then CheckMatrixLocMin:=False;
  if (y>1) and (x>1) then
   if mat[x,y]>=mat[x-1,y-1] then CheckMatrixLocMin:=False;
  if (y<N) and (x<M) then    if mat[x,y]>=mat[x+1,y+1] then CheckMatrixLocMin:=False;
  if (y>1) and (x<M) then    if mat[x,y]>=mat[x+1,y-1] then CheckMatrixLocMin:=False;
  if (y<N) and (x>1) then
   if mat[x,y]>=mat[x-1,y+1] then CheckMatrixLocMin:=False;
 end;
 
begin
 Write('N: ');
 Readln(N);
 Write('M: ');
 Readln(M);
 
 for  i:=1 to M do
  begin
   writeln(i,': ');
   for j:=1 to N do
    begin
     Write(j,' : ');
     Read(a[i,j]);
    end;
  end;
 
 for  i:=1 to M do
   for j:=1 to N do
     if CheckMatrixLocMin(a,i,j) then a[i,j]:=0;
 
 for  i:=1 to M do
  begin
   for j:=1 to N do
    begin
     Write(' : ',a[i,j]);
    end;
   writeln(' : ');
  end;
end.
									




Matrix. Абрамян
Matrix 1 Просмотров: 11745
Matrix 2 Просмотров: 4310
Matrix 3 Просмотров: 4441
Matrix 4 Просмотров: 3317
Matrix 5 Просмотров: 4963
Matrix 6 Просмотров: 3296
Matrix 7 Просмотров: 4054
Matrix 8 Просмотров: 3089
Matrix 9 Просмотров: 3968
Matrix 10 Просмотров: 2823
Matrix 11 Просмотров: 4290
Matrix 12 Просмотров: 2993
Matrix 13 Просмотров: 2939
Matrix 14 Просмотров: 1884
Matrix 15 Просмотров: 2570
Matrix 16 Просмотров: 2456
Matrix 17 Просмотров: 4292
Matrix 18 Просмотров: 2110
Matrix 19 Просмотров: 2772
Matrix 20 Просмотров: 3186
Matrix 21 Просмотров: 3207
Matrix 22 Просмотров: 1944
Matrix 23 Просмотров: 4419
Matrix 24 Просмотров: 2170
Matrix 25 Просмотров: 2345
Matrix 26 Просмотров: 2018
Matrix 27 Просмотров: 1979
Matrix 28 Просмотров: 1880
Matrix 29 Просмотров: 1792
Matrix 30 Просмотров: 1740
Matrix 31 Просмотров: 1469
Matrix 32 Просмотров: 1337
Matrix 33 Просмотров: 1434
Matrix 34 Просмотров: 1769
Matrix 35 Просмотров: 1494
Matrix 36 Просмотров: 1572
Matrix 37 Просмотров: 1307
Matrix 38 Просмотров: 1403
Matrix 39 Просмотров: 1330
Matrix 40 Просмотров: 1351
Matrix 41 Просмотров: 1101
Matrix 42 Просмотров: 1443
Matrix 43 Просмотров: 1114
Matrix 44 Просмотров: 1119
Matrix 45 Просмотров: 1156
Matrix 46 Просмотров: 1216
Matrix 47 Просмотров: 1381
Matrix 48 Просмотров: 1171
Matrix 49 Просмотров: 1195
Matrix 50 Просмотров: 1513
Matrix 51 Просмотров: 1352
Matrix 52 Просмотров: 1340
Matrix 53 Просмотров: 1198
Matrix 54 Просмотров: 985
Matrix 55 Просмотров: 1049
Matrix 56 Просмотров: 844
Matrix 57 Просмотров: 1029
Matrix 58 Просмотров: 1275
Matrix 59 Просмотров: 1050
Matrix 60 Просмотров: 971
Matrix 61 Просмотров: 1006
Matrix 62 Просмотров: 989
Matrix 63 Просмотров: 1137
Matrix 64 Просмотров: 1139
Matrix 65 Просмотров: 1015
Matrix 66 Просмотров: 857
Matrix 67 Просмотров: 888
Matrix 68 Просмотров: 993
Matrix 69 Просмотров: 870
Matrix 70 Просмотров: 988
Matrix 71 Просмотров: 823
Matrix 72 Просмотров: 863
Matrix 73 Просмотров: 940
Matrix 74 Просмотров: 890
Matrix 75 Просмотров: 787
Matrix 76 Просмотров: 909
Matrix 77 Просмотров: 931
Matrix 78 Просмотров: 868
Matrix 79 Просмотров: 920
Matrix 80 Просмотров: 2495
Matrix 81 Просмотров: 1262
Matrix 82 Просмотров: 970
Matrix 83 Просмотров: 1361
Matrix 84 Просмотров: 869
Matrix 85 Просмотров: 944
Matrix 86 Просмотров: 874
Matrix 87 Просмотров: 962
Matrix 88 Просмотров: 775
Matrix 89 Просмотров: 786
Matrix 90 Просмотров: 944
Matrix 91 Просмотров: 812
Matrix 92 Просмотров: 773
Matrix 93 Просмотров: 796
Matrix 94 Просмотров: 944
Matrix 95 Просмотров: 779
Matrix 96 Просмотров: 880
Matrix 97 Просмотров: 894
Matrix 98 Просмотров: 1038
Matrix 99 Просмотров: 1010
Matrix 100 Просмотров: 1126

Комментарии

Чтобы написать комментарии вам нужно войти в систему или зарегистрироваться



Заявка на расчет