calculate the sum of diagonals in a matrix

前端 未结 5 1657
梦如初夏
梦如初夏 2020-12-16 01:45

I need to calculate the sum of two diagonals in a matrix in C++, I already have a solution for that but I must be dumb because I cant understand what it is doing, so I would

5条回答
  •  没有蜡笔的小新
    2020-12-16 02:24

    int num[5][5]={0}; //decleration
    int i=0,j=0,sum=0; 
    for (int i=0;i<5;i++)
    {
        for (int j=0;j<5;j++)
        {
            cin>>num[i][j];
        }                          //Taking Matrix input
    }
            cout<

提交回复
热议问题