2016年嵌入式軟體工程師面試題(附答案)
嵌入式軟體工程師主要從事嵌入式軟體開發工作。涉及應用層以及底層軟體開發和設計工作。下面YJBYS小編為大家整理了關於2016嵌入式軟體工程師面試題,希望對你有所幫助。
1、將一個連結串列逆序
LinkList *reverse(LinkList *head)
{
LinkList *p1,*p2 = NULL,*p3 = NULL;
if(head == NULL || head->next == NULL)
return head;
p1 = head->next;
while(p1!=NULL)
{
p3 = p1->next;
p1->next = p2;
p2 = p1;
p1 = p3;
}
head->next = p2;
// head = p2;
return head;
}
2、計算一個位元組裡(byte)裡面有多少bit被置1
#include
int comb(const int c)
{
int count = 0;
int i = 0;
int cc = c;
while(i++<8)
{
if((cc&1)==1)
{
count++;
}
cc = cc>>1;
}
return count;
}
int main()
{
const int c = 0xcf;
printf("%dn",comb(c));
return 1;
}
3、在一個字串中找到可能的最長的子字串
#include
#include
#include
char *commanstring(char shortstring[],char longstring[])
{
int i,j;
char *substring = malloc(256);
if(strstr(longstring,shortstring)!=NULL)
return shortstring;
for(i=strlen(shortstring)-1;i>0;i--)
{
for(j=0;j<=strlen(shortstring)-i;j++)
{
memcpy(substring,&shortstring[j],i);
substring[i]='