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, 1];
- count := 3;
- one := 1;
- two := 1;
- for k := 1 to 8 do
- begin
- if ((k mod 2) <> 0) then
- one := 1 + one;
- i := one;
- if ((k mod 2) = 0) then
- two := 1 + two;
- j := two;
- while (i <= 5) and (j >= 1) do
- begin
- if (count = (i + j)) then
- begin
- sum := sum + myArray[i, j];
- writeln(i,j);
- end;
- inc(i);
- dec(j);
- end;
- inc(count);
- end;
- Writeln('popa ', sum);
- ReadLn;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement