Home > Back-end >  Ask, where is my program has a problem, thank you
Ask, where is my program has a problem, thank you

Time:01-25

This is the problem: enter a 3 line 3 columns of the matrix (any data type, integer or floating point), write a function to matrix column calculating mean, stored in a one-dimensional array, output in the main function of the one dimensional array
Example:
Hypothesis 3 rows 3 columns of the matrix to
1 2 3

4 5 6

7 8 9
The output of 4.00 5.00 6.00 (keep two decimal places)
This is my code:
# include
Void business (float x, float y, float z) {
Float b=(x + y + z)/3;
Printf (" % 2 f ", b);
}
Int main ()
{
int i,j;
Float a [3] [3], b;
for(i=0; i<3; I++) {
for(j=0; j<3; J++)
The scanf (" % f ", & amp; A [3] [3]);
}
for(j=0; j<3; J++) {
Business (a [0] [j], a [1] [j], a [2] [j]);
}
return 0;
}
I run results see picture

CodePudding user response:

Vc + + 6.0 my favourite, no one
 # include 
Void business (float x, float y, float z) {
Float b=(x + y + z)/3;
Printf (" % 2 f ", b);//add Spaces - output, more beautiful -- -- -- -- -- -- -- -- -- -- --
}
Int main (int arg c, char * argv [])
{
int i,j;
Float a [3] [3], b;
for(i=0; i<3; I++) {
for(j=0; j<3; J++)
The scanf (" % f ", & amp; A [I] [j]);//-- -- -- -- -- -- -- -- & amp; A [3] [3] to & amp; A [I] [j] -- -- -- -- -- -- -- -- --
}
for(j=0; j<3; J++) {
Business (a [0] [j], a [1] [j], a [2] [j]);
}
return 0;
}

Vc + + 6.0 debugging

CodePudding user response:

Crab crab bosses!!!!!