Home > Back-end >  Who can teach me, just contact with C language, a dork!
Who can teach me, just contact with C language, a dork!

Time:11-06

Programming read five rows 4 column matrix in the first four lines 3 columns integer (the following diagram, data variable), then the sum of all, the sum of the columns and the sum of all Numbers out, and corresponding to fill in the last column in the table, place the last line and the bottom right hand corner of the matrix and the output,
7 8 9
4 5 6
1 2 3
9 8 7

The input description
In line 12 digits in order of priority, in turn, input matrix, each row enter an integer,

Output description
In the form of a square matrix output the whole matrix of the data, format control for: printf (" % 4 d ", a [I] [j]);

CodePudding user response:

#include
Int main ()
{
Int a [5] [4]={0};
int i,j;
for(i=0; i<4. I++)
{
for(j=0; j<3; J++)
The scanf (" % d ", & amp; A [I] [j]);
}
for(i=0; i<4. I++)
{
for(j=0; j<3; J++)
{
If (i<4 & amp; & j<3)
{
A [I] [3]=[I] a [3] + [I] a [j];
}
A [4] [I]=[4] a [I] + [j] a [I];

}
}

for(i=0; i<5; I++)
{
for(j=0; j<4. J++)
Printf (" % 4 d ", a [I] [j]);
printf("\n");

}
return 0;
}

My answer

CodePudding user response:

... That calculate the accumulative j<3 to j<4
There is a little small mistakes

CodePudding user response:


#include
Int main ()
{
Int a [5] [4]={0};
int i,j;
for(i=0; i<4. I++)
{
for(j=0; j<3; J++)
The scanf (" % d ", & amp; A [I] [j]);
}
for(i=0; i<4. I++)
{
for(j=0; j<4. J++)
{
If (i<4 & amp; & j<3)
{
A [I] [3]=[I] a [3] + [I] a [j];
}
A [4] [I]=[4] a [I] + [j] a [I];

}
}

for(i=0; i<5; I++)
{
for(j=0; j<4. J++)
Printf (" % 4 d ", a [I] [j]);
printf("\n");

}
return 0;
}

CodePudding user response:

Thank you - thank you very much!
  • Related