Give ranks to a list without sorting in C
<p>I try to give the rank to the data, but the result is not what i expected.My for {} is as below :</p>

<pre><code>    for(i = 0; i &lt; 100; i++) 
{
    int curRank=1;

    for (j = 0; j &lt; i; j++)  
                              //  add x[i] to list, need to update the ranks. 
    {
        if (x[i] &gt; x[j]) 
        {                      // Update rank of x[i]
            curRank++;
        } 
        else 
        {                  // A number smaller than x[j] has appeared. Update rank of x[j]
            rank[j]++;
        }
    }

    rank[i]=curRank;
    printf("%lf %d\n", x[i],rank[i]);
}
</code></pre>

<p>And the result turns out like this:</p>

<pre><code>30.000000 1
71.510000 2
 3.300000 1
87.440000 4
53.420000 3
63.160000 4
89.100000 7
25.750000 2
.......
</code></pre>

<p>Clearly, it is wrong. Could anyone help me with this? Thank you.</p>