По разделам

 

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


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

Код (Pascal)

program Matrix75;
type
  matrix = array [1..10,1..10] of integer;
 
var
  a:matrix;
  K, M, N, i, j:Integer;
 
Function CheckMatrixLocMax(var mat:matrix; X,Y:Integer):Boolean;
 Begin
  CheckMatrixLocMax:=true;
  if x>1 then
   if mat[x,y]<=mat[x-1,y] then CheckMatrixLocMax:=False;
  if x1 then
   if mat[x,y]<=mat[x,y-1] then CheckMatrixLocMax:=False;
  if y1) and (x>1) then
   if mat[x,y]<=mat[x-1,y-1] then CheckMatrixLocMax:=False;
  if (y<N) and (x<M) then
   if mat[x,y]<=mat[x+1,y+1] then CheckMatrixLocMax:=False;   if (y>1) and (x<M) then
   if mat[x,y]<=mat[x+1,y-1] then CheckMatrixLocMax:=False;
  if (y<N) and (x>1) then
   if mat[x,y]<=mat[x-1,y+1] then CheckMatrixLocMax:=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 CheckMatrixLocMax(a,i,j) then a[i,j]:=(-1)*a[i,j];
 
 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 Просмотров: 11667
Matrix 2 Просмотров: 4271
Matrix 3 Просмотров: 4393
Matrix 4 Просмотров: 3275
Matrix 5 Просмотров: 4937
Matrix 6 Просмотров: 3241
Matrix 7 Просмотров: 4024
Matrix 8 Просмотров: 3045
Matrix 9 Просмотров: 3934
Matrix 10 Просмотров: 2779
Matrix 11 Просмотров: 4260
Matrix 12 Просмотров: 2956
Matrix 13 Просмотров: 2903
Matrix 14 Просмотров: 1851
Matrix 15 Просмотров: 2530
Matrix 16 Просмотров: 2434
Matrix 17 Просмотров: 4244
Matrix 18 Просмотров: 2082
Matrix 19 Просмотров: 2739
Matrix 20 Просмотров: 3146
Matrix 21 Просмотров: 3171
Matrix 22 Просмотров: 1910
Matrix 23 Просмотров: 4385
Matrix 24 Просмотров: 2144
Matrix 25 Просмотров: 2308
Matrix 26 Просмотров: 1982
Matrix 27 Просмотров: 1943
Matrix 28 Просмотров: 1851
Matrix 29 Просмотров: 1757
Matrix 30 Просмотров: 1704
Matrix 31 Просмотров: 1438
Matrix 32 Просмотров: 1312
Matrix 33 Просмотров: 1407
Matrix 34 Просмотров: 1743
Matrix 35 Просмотров: 1460
Matrix 36 Просмотров: 1548
Matrix 37 Просмотров: 1282
Matrix 38 Просмотров: 1368
Matrix 39 Просмотров: 1298
Matrix 40 Просмотров: 1315
Matrix 41 Просмотров: 1073
Matrix 42 Просмотров: 1399
Matrix 43 Просмотров: 1087
Matrix 44 Просмотров: 1086
Matrix 45 Просмотров: 1120
Matrix 46 Просмотров: 1181
Matrix 47 Просмотров: 1351
Matrix 48 Просмотров: 1133
Matrix 49 Просмотров: 1162
Matrix 50 Просмотров: 1483
Matrix 51 Просмотров: 1323
Matrix 52 Просмотров: 1309
Matrix 53 Просмотров: 1161
Matrix 54 Просмотров: 961
Matrix 55 Просмотров: 1025
Matrix 56 Просмотров: 815
Matrix 57 Просмотров: 988
Matrix 58 Просмотров: 1252
Matrix 59 Просмотров: 1008
Matrix 60 Просмотров: 948
Matrix 61 Просмотров: 975
Matrix 62 Просмотров: 961
Matrix 63 Просмотров: 1109
Matrix 64 Просмотров: 1101
Matrix 65 Просмотров: 989
Matrix 66 Просмотров: 833
Matrix 67 Просмотров: 851
Matrix 68 Просмотров: 962
Matrix 69 Просмотров: 836
Matrix 70 Просмотров: 955
Matrix 71 Просмотров: 793
Matrix 72 Просмотров: 832
Matrix 73 Просмотров: 906
Matrix 74 Просмотров: 867
Matrix 75 Просмотров: 757
Matrix 76 Просмотров: 879
Matrix 77 Просмотров: 906
Matrix 78 Просмотров: 841
Matrix 79 Просмотров: 889
Matrix 80 Просмотров: 2457
Matrix 81 Просмотров: 1220
Matrix 82 Просмотров: 933
Matrix 83 Просмотров: 1330
Matrix 84 Просмотров: 840
Matrix 85 Просмотров: 906
Matrix 86 Просмотров: 843
Matrix 87 Просмотров: 935
Matrix 88 Просмотров: 753
Matrix 89 Просмотров: 758
Matrix 90 Просмотров: 910
Matrix 91 Просмотров: 778
Matrix 92 Просмотров: 736
Matrix 93 Просмотров: 767
Matrix 94 Просмотров: 910
Matrix 95 Просмотров: 752
Matrix 96 Просмотров: 854
Matrix 97 Просмотров: 870
Matrix 98 Просмотров: 1012
Matrix 99 Просмотров: 984
Matrix 100 Просмотров: 1097

Комментарии

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



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