Home > Back-end >  For help, why go wrong
For help, why go wrong

Time:11-28

#include
2//# define N N is the number of M is subject for
# define M 3
Float score [N] [M].
Float a_stu [N].
Float a_cour [M];
Int a, b;//mark the location of the highest score
Int main ()
{
Int I, m;
Float h;
Void input_stu (void);
Void aver_stu (void);//students score
Void aver_cour (void);//subject score
Float highest (void);//performance is the largest, and the corresponding and subject
Float fancha (void);//variance
Input_stu ();
Aver_stu ();
Aver_cour ();

Printf (" student cour1 cour2 cour3 aver \ n ");
for (i=0; I & lt; N; I++)

Printf (" \ n % 5 d ", I + 1);
{
For (m=0; M & lt; M; M++)
Printf (" % 8.2 f ", score [I] [m]);
Printf (" % 8.2 f \ n ", a_stu [I]);
}

For (m=0; M & lt; M; M++)
Printf (" course aver % d: % f \ n ", m + 1, a_cour [m]);
H=highest ();
Printf (" student % d 'scour % d highese socre: % f ", a, b, h);
return 0;
}

Void input_stu (void)
{
Int I, m;
for (i=0; I & lt; N; I++)
{
Printf (" \ ninput student % d 's score \ n ", I + 1);
For (m=0; M & lt; M; M++)
Scanf_s (" % f ", & amp; Score [I] [m]);
}
}
Void aver_stu (void)
{int I, m;
Float sum=0, aver;
for (i=0; I & lt; N; I++)
{
For (m=0; M & lt; M; M++)
{
Sum=sum + score [I] [m].
}
A_stu [I]=sum/M (float);
}
}
Void aver_cour (void)
{
Int I, m;
Float sum=0, aver;
for (i=0; I & lt; M; I++)
{
For (m=0; M & lt; N; M++)
{
Sum=sum + score [I] [m].
}
A_cour [I]=sum/(float) N;
}
}
Float highest ()
{
Int I, m;
Float high;
High score=[0] [0];
for (i=0; I & lt; M; I++)
{
For (m=0; M & lt; N; M++)
{
If (high & gt; Score [I] [m])
{
High score=[I] [m].
B + 1;
}
A + 1;

}
Return (high);
}
}
Float fancha (void)
{
Int I, m;
Float n, sum=0;
for (i=0; I & lt; N; I++)
{

For (m=0; M & lt; M; M++)
Sum=sum + (score [I] [m] - a_stu [N]) * (score [I] [m] - a_stu [N]);
}
N=sum/n;
Return (n);
}

CodePudding user response:

Haven't made a mistake, the program runs to the back of the last sentence, pulled out of the normal,

CodePudding user response:

reference 1/f, zhao teacher reply:
no mistake, the program runs to the back of the last sentence, normal withdrew,

It does not I want results

CodePudding user response:

refer to the second floor weixin_50958121 response:
Quote: reference, 1/f, zhao teacher reply:
no mistake, programs run at the back of the last sentence, normal withdrew,

It's not what I want results

The output results began to wrong there

CodePudding user response:

refer to the second floor weixin_50958121 response:
Quote: reference, 1/f, zhao teacher reply:
no mistake, programs run at the back of the last sentence, normal withdrew,

It's not what I want results

It?? Said the array a problem there

CodePudding user response:

The float highest () function has a problem, change as follows, for reference:
Float highest ()
{
Int I, m;
Float high;
High score=[0] [0];
For (I=0; I & lt; N; I++)
{
For (m=0; M & lt; M; M + +)
If (high & lt; Score [I] [m])
{
High score=[I] [m].
B=m;
A=I;
}
}
Return high;
}

CodePudding user response:

Again carefully watched, void aver _cour (void) function, two for () loop conditions, M N put the wrong position, for outside (I=0; i CodePudding user response:

The float fancha (void);//variance function didn't what to use? The overall changes as follows, for reference:
 # include 
2//# define N N is the number of M is subject for
# define M 3

Float score [N] [M]={0};
Float a_stu [N]={0};
Float a_cour [M]={0};
Int a, b;//mark the location of the highest score

Int main (int arg c, char * argv [])
{
Int I, m;
Float h;
Void input_stu (void);
Void aver_stu (void);//students score
Void aver_cour (void);//subject score
Float highest (void);//performance is the largest, and the corresponding and subject
Float fancha (void);//variance

Input_stu ();
Aver_stu ();
Aver_cour ();

Printf (" student cour1 cour2 cour3 aver \ n ");
for (i=0; I & lt; N; I++)
{printf (" \ n % 5 d ", I + 1);
For (m=0; M & lt; M; M++)
Printf (" % 8.2 f ", score [I] [m]);
Printf (" % 8.2 f \ n ", a_stu [I]);
}

For (m=0; M & lt; M; M++)
Printf (" course aver % d: % f \ n ", m + 1, a_cour [m]);

H=highest ();
Printf (" student % d 'scour % d highese socre: % f \ n ", a + 1, + 1 b, h);
//system (" pause ");
return 0;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void input_stu (void)
{
Int I, m;
for (i=0; I & lt; N; I++)
{
Printf (" \ ninput student % d 's score \ n ", I + 1);
For (m=0; M & lt; M; M++)
The scanf (" % f ", & amp; Score [I] [m]);
}
}

Void aver_stu (void)
{
Int I, m;
Float sum, aver;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related