Suppose a teacher enters the exam score according to the student seat number, and now I hope that the student score is automatically displayed after the input is completed, and of course the students' scores may be the same. This problem is basically difficult, as long as an additional quotation array visits the fractional array, directly use the following program fragment:
For (i = 0; i Juni [i] = 1; For (j = 0; j IF (Score [J]> Score [I]) Juni [i] ; } } Printf ("Score / T Rank / N"); For (i = 0; i Printf ("% d / t% d / n", score [i], juni [i]); The above method is simple, but the number of times of the aeration is n ^ 2, if the n value is large, then the time of the calculation will be dragged; change the length of the JUni array to N 2, and set the initial value to 0, as follows Down: Next, visit the score array and add 1 on the quotation array index element corresponding to the score, as shown below: Set the rightmost element of the ranking array to 1, then sequentially add the elements of the right to the left one element, and the "score 1" in the last ranking array is the ranking of the score, as shown below: This way seems complicated, but in the number of people before calculating a score, it is assumed that the number of ranks before 89 is x 1, which is why the rightmost right side of the ranking array is set to 1 The reason; if there is a Y person 89 points, 88 points naturally x y 1, the reason why the entire array right element is added to the left. If the score has a negative score, since the C / C or Java equation language cannot handle the negative index, a offset value must be added, and all the scores are first shifted to one range, and finally displayed Remember to reduce the offset value. Import java.io. *; public class scorerank {