Home > Back-end >  A C language programming problem
A C language programming problem

Time:09-23

Assuming that the number of students is no more than 100, the number of students from the keyboard input n and n scores in the array, maximum, minimum, average, the number of failed,

CodePudding user response:

Such an array of questions, not hard is a sorting and judgment

CodePudding user response:

reference 1st floor CHXCHXKKK response:
array as the topic is not difficult, is a sorting and judgment

Just learning C language, I made a morning

CodePudding user response:

refer to the second floor qq_47712720 response:
Quote: refer to 1st floor CHXCHXKKK response:
array as the topic is not difficult, is a sorting and judgment

Just learning C language, I made a morning

Give you a idea
Define variables:
Int the Max and min.//maximum value, minimum value
Int I, sum=0, t=0;
Float avge; The average//
Int arr [10].//assume that 10 students
//array input should be
Max=arr [9].
Min=arr [0];
for (i=0; i<10; I++)
{
If (min & gt; A [I])
Min=a [I]//is smaller than the minimum value is assigned to the minimum
If (Max & lt; A [I])
Max=a [I]//is greater than the maximum value is assigned to a maximum
If (a [I] <60)
T++; Number of failed the//
The sum +=a [I];
}
Avge=sum * 1.0/10; The average//

The output of the Max min avge t

CodePudding user response:

I just try to make up for a moment, but there are still error but I don't know how to change
#include
Void main ()
{
Int the Max and min.
Int I, n, sum=0, t=0;
Int a [I];
Float avge;
Printf (" please input the number of students: ");
The scanf (" % d ", & amp; N);
Printf (" please enter the % d student performance: ");
{the for (I=0; iThe scanf (" % d ", & amp; A [I]);
Max=a [n - 1);
Min=a, [0].
for(i=0; i{if (min> A [I])
Min=a, [I].
If (maxMax=a, [I].
If (a [I] <60)
T++;
The sum +=a [I];
}
Avge=sum * 1.0/n;
A maximum printf (" % d \ n, minimum % d \ n, the number of failed the % d \ n, average % lf ", Max, min, t, avge);
}}

CodePudding user response:

 int main () 
{
Int Max, min, ave, unq;
int i;
int n;//number of students
The scanf (" % d ", & amp; N);
char c;
The scanf (" % c ", & amp; C);
Int STR [n].//
For (I=0; i{
The scanf (" % d ", & amp; STR [I]);
}
Max=STR [0].
Min=STR [0];
For (I=0; i{
If (STR [I] & gt; STR [I + 1])
{
Max=STR [I];
Min=STR [I + 1);
}
The else
{
Min=STR [I];
Max=STR [I + 1);
}
}
Unq=0;
For (I=0; i{
If (STR [I] <60)
{
Unq++;
}
}
Ave=0;
For (I=0; i{
Ave=ave + STR [I];
}
Ave=ave/n.
//print
}


The main plus output and probably is such,. H should be

CodePudding user response:

The
reference 5 floor response: string of implement
 int main () 
{
Int Max, min, ave, unq;
int i;
int n;//number of students
The scanf (" % d ", & amp; N);
char c;
The scanf (" % c ", & amp; C);
Int STR [n].//
For (I=0; i{
The scanf (" % d ", & amp; STR [I]);
}
Max=STR [0].
Min=STR [0];
For (I=0; i{
If (STR [I] & gt; STR [I + 1])
{
Max=STR [I];
Min=STR [I + 1);
}
The else
{
Min=STR [I];
Max=STR [I + 1);
}
}
Unq=0;
For (I=0; i{
If (STR [I] <60)
{
Unq++;
}
}
Ave=0;
For (I=0; i{
Ave=ave + STR [I];
}
Ave=ave/n.
//print
}


Probably is the case, the main plus output and. H should go

Thank you very much!!!!!!
I'll thank you thank you

CodePudding user response:

The
reference 5 floor response: string of implement
 int main () 
{
Int Max, min, ave, unq;
int i;
int n;//number of students
The scanf (" % d ", & amp; N);
char c;
The scanf (" % c ", & amp; C);
Int STR [n].//
For (I=0; i{
The scanf (" % d ", & amp; STR [I]);
}
Max=STR [0].
Min=STR [0];
For (I=0; i{
If (STR [I] & gt; STR [I + 1])
{
Max=STR [I];
Min=STR [I + 1);
}
The else
{
Min=STR [I];
Max=STR [I + 1);
}
}
Unq=0;
For (I=0; i{
If (STR [I] <60)
{
Unq++;
}
}
Ave=0;
For (I=0; i{
Ave=ave + STR [I];
}
Ave=ave/n.
//print
}


Probably is the case, the main plus output and. H should go

I see thank you
  • Related