Home > Back-end >  The calling function
The calling function

Time:11-28

#include
Int a LIST (int score [], long num [], int n);
Double AVER (int score [], long num [], int n, int I);
Int main (void)
{
int i;
Int fail=0;
Int n=0;
int count=0;
Int score [30].
Long num [30].
Score [0]=0;
Printf (" please enter the classmate student number and fraction \ n ");
for(i=1; Score] [I - 1 & gt;=0; I++)
{
The scanf (" % ld % d ", & amp; Num [I], & amp; Score [I]);
N++;
}
Printf (" failed the classmate student number and fraction respectively \ n ");
Fail=LIST (score, num, n);
Printf (" the number of the class for % d, the number of failed at % d \ n ", n - 1, fail);
return 0;
}
Int a LIST (int score [], long num [], int n)
{
Int the count, I;
count=0;
for(i=1; i<=n - 1; N++)
{
If (score [I] & gt;=0 & amp; & Score [I] <60)
{
Printf (" % 3 d \ \ n "t % 3 d, num [I], score [I]);
count++;
}
}
Return the count.
}
To enter student id and grades, when the input negative stop input, after and failed in the population, the total number of statistics and failed the student number and fraction of printed,
But the final result of an infinite loop the exam scores, why,

CodePudding user response:

LIST the function of the cycle: the for (I=1; I & lt;=n - 1; N++)
N++==& gt; i++

CodePudding user response:

For (I=1; I & lt;=n - 1; N the words of the n + + + +), I will always be a 1, die out in the loop,

CodePudding user response:

Because the upstairs has said;
 for (I=1; Score] [I - 1 & gt;=0; I++) 

Change
 for (I=1; I & lt; N & amp; & Score [I] & gt;=0; I++) 

To prevent cross -

CodePudding user response:

Want to along while have never thought is wrong here, thank you
  • Related