Home > database >  Pta7-2-2, two-dimensional arrays, matrix operations
Pta7-2-2, two-dimensional arrays, matrix operations

Time:09-28

Given a phalanx of n * n, a deputy diagonal matrix in addition to the subject requirements, the last column and the last line of the sum of all the elements, deputy diagonal as attachment from the upper right corner to the lower left corner of the matrix,
Input format:
Enter the first line gives positive integer n (1 & lt; N 10 or less); Then n lines, each line n integers, separated by Spaces,
The output format:
In one line in the matrix, in addition to the diagonal, the last column and the last line of the sum of all element,
Input the sample:
4
2, 3, 4, 1
5 6 1 1
7 8 1
1 1 1 1
The output sample:
35


The code
#include
Int main ()
{
Int n, m, d;
The scanf (" % d ", & amp; N);
Int I, j, c, a, [20] [20].
for(i=0; i{
for(j=0; j{
The scanf (" % d ", & amp; A [I] [j]);
}
}
D=0;
for(i=0; i{
C=0;
for(j=0; j{
if(i!=n - 1 | | j!=n - 1)
{
If (j!=n - 1 - I)
{
C=c + a, [I] [j].
}
}
}
D=d + c;
}
Printf (" % d ", d);
return 0;
}

I am a beginner, but also hope you bosses more directions!
  • Related