forked from paulusja/info1_uebungen
27 lines
536 B
C
27 lines
536 B
C
// TODO: Beginn
|
|
|
|
#include <stdlib.h>
|
|
#include "suche.h"
|
|
|
|
int *binsucheZgr(int suchElem, int *startZgr, int *endZgr)
|
|
{
|
|
while(startZgr <= endZgr)
|
|
{
|
|
int *mitte = startZgr + (endZgr - startZgr) / 2;
|
|
|
|
if(suchElem < *mitte)
|
|
endZgr = mitte - 1;
|
|
else if(suchElem > *mitte)
|
|
startZgr = mitte + 1;
|
|
else
|
|
return mitte;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
int *binsuche(int suchElem, int array[], unsigned int anzahl)
|
|
{
|
|
return binsucheZgr(suchElem, array, array + anzahl - 1);
|
|
}
|