Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program InputArray;
- {$APPTYPE CONSOLE}
- uses
- Windows, SysUtils;
- type
- TArray = array of array of Integer;
- var
- n, i, j, sum, count, two, one, k: Integer;
- myArray: TArray;
- begin
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- // Ввод размера массива
- Write('Введите размер массива: ');
- ReadLn(n);
- // Инициализация динамического массива
- SetLength(myArray, n, n);
- // Ввод значений массива
- for i := 0 to n - 1 do
- begin
- for j := 0 to n - 1 do
- begin
- Write('Введите значение для элемента [', i + 1, ',', j + 1, ']: ');
- ReadLn(myArray[i, j]);
- end;
- end;
- // Вывод массива
- Writeln('Введенный массив:');
- for i := 0 to n - 1 do
- begin
- for j := 0 to n - 1 do
- Write(myArray[i, j]:5);
- Writeln;
- end;
- sum := myArray[0, n - 1];
- one := n - 1;
- two := 0;
- count := n - 1;
- for k := 1 to 2 * (n - 1) do
- begin
- if (k mod 2 <> 0) then
- begin
- one := - 1 + one;
- count := n - 2;
- end;
- j := one;
- if (k mod 2 = 0) then
- begin
- two := 1 + two;
- count := n - 1;
- end;
- i := two;
- while ((i >= 0) and (j >= 0)) 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