//The following program can run efficiently and correctly!
# include & ltiostream & gt
Use namespace std
# Define N 5
Structural employee
{
char name[20];
Floating wages;
};
Int sort (int flag[], struct employee em[])
//Input: the flag array stores the index numbers of data elements before sorting;
//Output: Using selective sorting, the index numbers corresponding to the sorted data elements from the largest to the smallest are stored in the flag array.
{
int i,j,mark,temp
for(I = 0; I<n-1; i++)
{
mark = I;
for(j = I+ 1; j & ltn; j++)
if(em[flag[j]]。 Salary & gtem[flag[mark]]. Salary)
mark = j;
If (me! = Mark)
{
temp = flag[I];
flag[I]= flag[mark];
flag[mark]= temp;
}
}
Returns 0;
}
int main()
{
Structure employee em[N]={
{"Jimmy", 1250.04}, {"Tim", 1280.07},
{"Rose", 1390.08}, {"tommoy ",1490.35},
{"Jon", 1320.54}
};
int flag[N]={0, 1,2,3,4},I;
sort(flag,em);
cout & lt& lt”OUT:\ n”;
for(I = 0; I & ltn;; i++)
cout & lt& lt" The " & lt& ltI+ 1 & lt; & lt" th " & lt& ltem[flag[i]]。 Name & lt< ""< & ltem [flag [i]]. Salary & lt& ltendl
cout & lt& lt“OK”;
CIN & gt; & gt me;
Returns 0;
}
I hope kutpbpb's answer can help you!