順序查找
FUNC seq(ank):integer;
BEGIN I:=; A[n+]= __()____;
WHILE a[I]<>k DO I:=I+;
IF __()___ THEN return(I) ELSE return();
END; 【中山大學 四 (分)】
已知N元整型數組a存放N個學生的成績已按由大到小排序以下算法是用對分(折半)查找方法統計成績大於或等於X分的學生人數請填空使之完善(C語言PASCAL語言的考生不填)
#define N /*學生人數*/
int uprx(int a[N]int x ) /*函數返回大於等於X分的學生人數*/
{ int head=midrear=N;
do {mid=(head+rear)/;
if(x<=a[mid]) __()__ else __()__;
}while(__()__);
if (a[head]<x) return head;
return head; } 【西南交通大學 一】[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/22920.html