tarasowamash4
?>

10. 2. 8. 16 0 00 000 0000 1 01 101 0001 2 10 010 0010 3 11 011 0011 4 5 6 7 8 9

Информатика

Ответы

milanparipovic864

Вроде работает

#include <iostream>

using namespace std;

int main()

{

   int a;

   cin >> a;

   int mas[a][a];

   for(int i = 0; i<a; i++){

       for(int g = 0; g<a; g++){

           int t;

           cin >> t;

           mas[i][g] = t;

       }

   }

   for(int i = 0; i<a; i++){

       swap(mas[i][i] , mas[a-i-1][i]);

   }

   for(int i = 0; i<a; i++){

       for(int g = 0; g<a; g++){

           cout << mas[i][g] << ' ';

       }

       cout << endl;

   }

}

ivanjeka87

--- Python 3.7 ---

def MatrixRead(Rows, RowLength, ContType):

   for row in range(Rows):

       print('Enter line ' + str(row))

       buff = []

       [buff.append(ContType(input())) for _ in range(RowLength)]

       yield buff

       

def MatrixSwap(Matrix, OldPos:tuple, NewPos: tuple):

   Matrix[OldPos[0]][OldPos[1]], Matrix[OldPos[1]][OldPos[0]] = Matrix[NewPos[1]][NewPos[0]], Matrix[NewPos[0]][NewPos[1]]

   return Matrix

   

def MatrixPrint(Matrix, end = '\n'):

   for Row in Matrix:

       print(*Row, end ='\n')

   print(end)

   

   

def main():

   N = int(input()) #Matrix Size

   Matr =list( MatrixRead(N, N, int))

   MatrixPrint(Matr) #For check

   for row in range(N):

       for col in range(N):

           SecDiagPos = (row, N-col-1)

           MainDiagPos = (row, col)

           Matr = MatrixSwap(Matr, MainDiagPos, SecDiagPos)

   MatrixPrint(Matr)

   

if __name__ == '__main__':

   main()

Объяснение:

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

10. 2. 8. 16 0 00 000 0000 1 01 101 0001 2 10 010 0010 3 11 011 0011 4 5 6 7 8 9
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

Абдулганиева Сергей
shhelina
Svetlana191
akopsiroyan
dsnewline
Борисовна_Кашутина
Tyukalova
Staroverovanatasa494
titovass9
shmanm26
Karmelita1978
mskatrinmadness
tanyashevvvv
ИП-Сысоев1628
daarisgoy
▲