Home > Back-end >  Help bosses
Help bosses

Time:11-24

, the output of the code is how to return a responsibility excuse me, how can we exchange and compare two groups of average size?

CodePudding user response:

Is A garbled English you define the structure of the body has A problem ah char English [1] you save A character for A B C D character array must be to ensure that the array last for '\ 0' so you need to change to
Char [2]. English or directly char c; Use of the latter directly the==comparison line does not need to STRCMP

In addition should you want to input data so a [5] structure initialization will do not need to assign a value

Moreover you 21 for loop only four missed a student

Finally you not do you just cycles ave the array but the array an array of students is connected with you? Order even row in the array which students are well do you know which score?

Suggest more think

The following code for reference

 # include & lt; Iostream> 
using namespace std;

Typedef struct student
{
Char name [10].
Int id;
Char English;
Int math;
Int ave.
} STUDENT;
STUDENT a, [5]={0}.

Int main ()
{
int i, j;
For (I=0; I & lt; 5; I++)
Cin & gt;> A [I] name & gt;> A [I]. Id & gt;> A [I]. English & gt;> A [I]. Math;
Cout & lt; For (I=0; I & lt; 5; I++)
{
The switch (a [I]. English)
{
Case 'A' :
A [I] ave=(90 + a [I]. Math)/2;
break;
Case 'B' :
A [I] ave=(80 + a [I]. Math)/2;
break;
Case 'C' :
A [I] ave=(70 + a [I]. Math)/2;
break;
Case 'D' :
A [I] ave=(60 + a [I]. Math)/2;
break;
}
}
For (I=0; I & lt; 5; I++)
{
Cout & lt; }
Cout & lt;
STUDENT TMP.
For (I=0; I & lt; 5; I++)
{
For (j=I + 1; J & lt; 5; J++)
{
If (a [I] ave & gt; A [j]. Journal of ave)
{
TMP=a, [I].
a[i]=a[j];
A [j]=TMP;
}
}
}
For (I=0; I & lt; 5; I++)
{
Cout & lt;
}
}

CodePudding user response:

reference 1/f, 5250 response:
is A garbled English you define the structure of the body has A problem ah char English [1] you save A character for A B C D character array must be to ensure that the array last for '\ 0' so you need to change to
Char [2]. English or directly char c; Use of the latter directly the==comparison line does not need to STRCMP

In addition should you want to input data so a [5] structure initialization will do not need to assign a value

Moreover you 21 for loop only four missed a student

Finally you not do you just cycles ave the array but the array an array of students is connected with you? Order even row in the array which students are well do you know which score?

Suggest more think

The following code for reference

 # include & lt; Iostream> 
using namespace std;

Typedef struct student
{
Char name [10].
Int id;
Char English;
Int math;
Int ave.
} STUDENT;
STUDENT a, [5]={0}.

Int main ()
{
int i, j;
For (I=0; I & lt; 5; I++)
Cin & gt;> A [I] name & gt;> A [I]. Id & gt;> A [I]. English & gt;> A [I]. Math;
Cout & lt; For (I=0; I & lt; 5; I++)
{
The switch (a [I]. English)
{
Case 'A' :
A [I] ave=(90 + a [I]. Math)/2;
break;
Case 'B' :
A [I] ave=(80 + a [I]. Math)/2;
break;
Case 'C' :
A [I] ave=(70 + a [I]. Math)/2;
break;
Case 'D' :
A [I] ave=(60 + a [I]. Math)/2;
break;
}
}
For (I=0; I & lt; 5; I++)
{
Cout & lt;
}
Cout & lt;
STUDENT TMP.
For (I=0; I & lt; 5; I++)
{
For (j=I + 1; J & lt; 5; J++)
{
If (a [I] ave & gt; A [j]. Journal of ave)
{
TMP=a, [I].
a[i]=a[j];
A [j]=TMP;
}
}
}
For (I=0; I & lt; 5; I++)
{
Cout & lt;
}
}

Finally understand thank you!
  • Related