Home > Back-end >  Excuse me I'd like to have an array according to the order from big to small order, and output
Excuse me I'd like to have an array according to the order from big to small order, and output

Time:04-14

CodePudding user response:

Reference:
 # include & lt; Stdio. H> 
# define 40 N

Parr void reswap (int * and an int n);

Int main ()
{
Int score [N], N, I;
Printf (" The number of student: ");
The scanf (" % d ", & amp; n);

Printf (" Input student 's score: "% d, n);
for(i=0; i{
The scanf (" % d ", & amp; Score [I]);
}

Reswap (score, n);

return 0;
}

Parr void reswap (int * and an int n)
{
Int I, j, temp.
for(i=0; i{
for(j=i+1; j{
If (* (parr + I) & lt; * (parr + j))//from big to small
{
Temp=* (parr + I);
* (parr + I)=* (parr + j);
* (parr + j)=temp;
}
}
}
for(i=0; i{
Printf (" % d ", * (parr + I));
}
printf("\n");
}
  • Related