Home > Back-end >  Users need to input every students of three grades and the classmate's name is stored in the ar
Users need to input every students of three grades and the classmate's name is stored in the ar

Time:09-22

#include

# define N 100
Void main (void)
{

Int I, j, a, k, n, m;//n is the number of students, I j is the subscript
Int score [N] [3].
Float aver [N].
Float t;
int sum=0;


Printf (" please input to input result of student number \ n \ r ");
The scanf (" % d ", & amp; N);

Printf (" please input the students in turn three grades \ n \ r ");

for(i=0; i{
for(j=0; j<3; J++)

The scanf (" % d ", & amp; Score [I] [j]);

}


for(i=0; i
{
Sum=0;
for(j=0; j<3; J++)
The sum +=score [I] [j];
Aver [I]=sum/3.0;
}

for(i=0; i{
k=1;
for(j=i+1; j{
If (aver [k] K=j;

}
If (k!=I)
{

T=aver [I]; Aver [I]=aver [k]. Aver [k]=t;
for(m=0; m<3; M++)
{
A=score [I] [m].
Score [I] [m]=score [k] [m].
Score [k] [m]=a;


}
}


}



Printf (" the sorted score is: \ n ");
for(i=0; i{
for(j=0; j<3; J++)
Printf (" % d ", score [I] [j]);
Printf (" % 2 f \ n ", aver [I]);



}


}












Also sent a name information input and output don't know what to do for bosses to solve

CodePudding user response:

You can define a 2 d array such as name [100] [30] to store name

CodePudding user response:

I know that define an array but won't after the==

CodePudding user response:

reference 1/f, Simple, Soft reply:
you can define a 2 d array such as name [100] [30] to store name
please help me to write it

CodePudding user response:

Use a structure array
 struct {
Char name [];
Int score [3].
} student [];

CodePudding user response:

The
reference 5 floor response: string of implement
use a struct array
 struct {
Char name [];
Int score [3].
} student [];
would you help me write the complete code, thank you

CodePudding user response:

This topic structure is commonly used in the array

CodePudding user response:

refer to 7th floor CHXCHXKKK response:
this topic structure is commonly used in the array
can help me to write a complete code?
  • Related