嵌入式工程師面試中常出現的算法

嵌入式系統是以應用爲中心,以計算機技術爲基礎,並且軟硬件可裁剪,適用於應用系統對功能、可靠性、成本、體積、功耗有嚴格要求的專用計算機系統。下面YJBYS小編爲大家整理了關於嵌入式工程師面試中經常出現的算法文章,希望對你有所幫助。

嵌入式工程師面試中常出現的算法

  二分查找的代碼.

int bfind(int* a,int len,int val)

{

int m = len/2;

int l = 0;

int r = len;

while(l!=m && r!= m)

{

if(a[m] > val)

{

r = m;

m = (m+l)/2;

}

else if(a[m] < val)

{

l = m;

m = (m+r)/2;

}

else

return m;

}

return -1; //沒有找到

}

  寫出在母串中查找子串出現次數的代碼.

int count1(char* str,char* s)

{

char* s1;

char* s2;

int count = 0;

while(*str!='