0

当数组中有重复值时,我需要找到第一个超过 x[floor(0.8*N)+1] 的数字。但我不确定如何做到这一点。x 指的是按升序排序的整数数组。非常感谢您的帮助。

void eightypercentile(int x[], values)
{
  int eightiethpercentile;
  if( x[floor(0.9*N)+1] <= x[floor(0.8*N)])
  {
    eightiethpercentile = /*first number that exceeds x[floor(0.8*N)+1] */
  }
  int eightiethpercentile = x[floor(0.8*N)+1];

}
4

1 回答 1

0

一种方法:

nc = ceil(N * 0.8)
nf = floor(N * 0.8)
if (nc == nf) nc++;
while (x[nc] == x[nc-1]) 
  nc++;
return x[nc];
于 2012-11-15T00:19:15.683 回答