Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program InputArray;
- {$APPTYPE CONSOLE}
- uses
- Windows, SysUtils;
- const
- ArraySize = 5; // Размер массива
- type
- TArray = array [1 .. ArraySize, 1 .. ArraySize] of Integer;
- var
- myArray: TArray;
- i, j, sum, count, two, one, k: Integer;
- begin
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- // Ввод значений массива
- for i := 1 to ArraySize do
- begin
- for j := 1 to ArraySize do
- begin
- Write('Введите значение для элемента [', i, ',', j, ']: ');
- ReadLn(myArray[i, j]);
- end;
- end;
- // Вывод массива
- Writeln('Введенный массив:');
- for i := 1 to ArraySize do
- begin
- for j := 1 to ArraySize do
- Write(myArray[i, j]:5);
- Writeln;
- end;
- sum := myArray[1, 5];
- one := 5;
- two := 1;
- count :=5;
- for k := 1 to 8 do
- begin
- if ((k mod 2) <> 0) then
- begin
- one := - 1 + one;
- count := 5;
- end;
- j := one;
- if ((k mod 2) = 0) then
- begin
- two := 1 + two;
- count := 6;
- end;
- i := two;
- while ((i>=1) and (j >= 1)) do
- begin
- if (count = (i + j)) then
- begin
- sum := sum + myArray[i, j];
- writeln(i,j);
- end;
- dec(j);
- dec(i);
- count := count - 2;
- end;
- end;
- Writeln('popa ', sum);
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement