User:Trieu/Method of rank
Appearance
Suppose we want to rank students according to their examination's results.
There are n students
Let $mark[1->n] be an array which contains mark of all student from 1 to n respectively, and $rank[1->n] will be contained the rank of student after finding out. Namely , $mark[1] = mark of student 1, and $rank[1] = rank of student 1. We need determine rank[i] (i=1->n) for all students.
$m=1;
$k=1;
while ($m<=$n) {
$max=$mark[$m];
$rank[$m]=1;
$k=1;
while ($k<=$n) {
if (($max<$mark[$k])&&($m!=$k)) { $rank[$m]++; }
$k++;
}
$m++;
}
Note:
The above illustration is written with PHP.