嵌入式工程师面试题经典.docx
- 文档编号:25768122
- 上传时间:2023-06-13
- 格式:DOCX
- 页数:13
- 大小:15.92KB
嵌入式工程师面试题经典.docx
《嵌入式工程师面试题经典.docx》由会员分享,可在线阅读,更多相关《嵌入式工程师面试题经典.docx(13页珍藏版)》请在冰豆网上搜索。
嵌入式工程师面试题经典
1、将一个字符串逆序
2、将一个链表逆序
3、计算一个字节里(byte)里面有多少bit被置1
4、搜索给定的字节(byte)
5、在一个字符串中找到可能的最长的子字符串
6、字符串转换为整数
7、整数转换为字符串
style="MARGIN:
0px;COLOR:
rgb(102,102,102);LINE-HEIGHT:
150%"wrap="break-word"1、char*strconv(char*p)
{
inti,length;
chartemp;
length=strlen(p);
for(i=0;i { temp=*(p+i); *(p+i)=*(p+length-1-i); *(p+length-1-i)=temp; } returnp; } intmain() { charsrc[100]; char*p; scanf("%s",src); p=strconv(src); printf("%s\n",p); return0; } style="MARGIN: 0px;COLOR: rgb(102,102,102);LINE-HEIGHT: 150%"wrap="break-word"3、intcal(intdata)//calculationthenumberofbitinonebyte { inta; intcount=0; a=data%100; while(a! =0) { count+=a%2; a/=2; } returncount; } intmain() { intd,count; scanf("%d",&d); count=cal(d); printf("%dofone\n",count); return0; } style="MARGIN: 0px;COLOR: rgb(102,102,102);LINE-HEIGHT: 150%"wrap="break-word"4、#include #include voidfindmax(char*p) { intj=0,max=0; intcount=0; charrecord[200]; charrecordmax[200]; for(inti=0;;i++) { if((*(p+i)=='')||(*(p+i)=='\0')) { if(count>max) { max=count; record[j]='\0'; strcpy(recordmax,record); } count=0; j=0; } else { record[j]=*(p+i); count++; j++; } if(*(p+i)=='\0') break; } printf("%s\n",recordmax); } intmain() { charstr[]="zengweidsfdsaflangdhah"; printf("%s\n",str); findmax(str); return0; } style="MARGIN: 0px;COLOR: rgb(102,102,102);LINE-HEIGHT: 150%"wrap="break-word"#include #include #include typedefstructshopping { chargoods[100]; structshopping*next; }SHOP; SHOP*buildlink()//创建链表 { chargoods[100]; SHOP*head,*p,*h; p=(SHOP*)malloc(sizeof(SHOP)); head=p; head->next=NULL; printf("Inputthreegoods: "); for(inti=0;i<3;i++) { scanf("%s",goods); p=(SHOP*)malloc(sizeof(SHOP)); strcpy(p->goods,goods); p->next=NULL; if(head->next==NULL) { head->next=p; h=p; } else { h->next=p; h=h->next; } } returnhead; } voidshowlink(SHOP*head)//显示链表 { SHOP*p; p=head->next; while(p! =NULL) { printf("%s",p->goods); p=p->next; } printf("\n"); } SHOP*revlink(SHOP*head)//反转链表 { SHOP*p,*newp; p=head->next; head->next=NULL; while(p! =NULL) { newp=p; p=p->next; newp->next=head->next; head->next=newp; } returnhead; } intdelnode(SHOP*head,char*str) { //deletesuccessreturn1,elsereturn0 SHOP*q,*p=head; while(p->next! =NULL) { q=p; p=p->next; if(! strcmp(str,p->goods)) { q->next=p->next; free(p); //p=q->next; return1; } } return0; } intmain() { SHOP*head; SHOP*newhead; head=buildlink(); showlink(head); newhead=revlink(head); showlink(newhead); showlink(head); printf("Deleteanode: "); charstr[50]; scanf("%s",str); inti; i=delnode(head,str); showlink(head); if(i==1) printf("Deletesuccessful! \n"); return0; } style="MARGIN: 0px;COLOR: rgb(102,102,102);LINE-HEIGHT: 150%"wrap="break-word"#include #include #include typedefstructshopping { chargoods[100]; structshopping*next; }SHOP; SHOP*buildlink()//创建链表 { chargoods[100]; SHOP*head,*p,*h; p=(SHOP*)malloc(sizeof(SHOP)); head=p; head->next=NULL; printf("Inputthreegoods: "); for(inti=0;i<3;i++) { scanf("%s",goods); p=(SHOP*)malloc(sizeof(SHOP)); strcpy(p->goods,goods); p->next=NULL; if(head->next==NULL) { head->next=p; h=p; } else { h->next=p; h=h->next; } } returnhead; } voidshowlink(SHOP*head)//显示链表 { SHOP*p; p=head->next; while(p! =NULL) { printf("%s",p->goods); p=p->next; } printf("\n"); } SHOP*revlink(SHOP*head)//反转链表 { SHOP*p,*newp; p=head->next; head->next=NULL; while(p! =NULL) { newp=p; p=p->next; newp->next=head->next; head->next=newp; } returnhead; } intdelnode(SHOP*head,char*str) { //deletesuccessreturn1,elsereturn0 SHOP*q,*p=head; while(p->next! =NULL) { q=p; p=p->next; if(! strcmp(str,p->goods)) { q->next=p->next; free(p); //p=q->next; return1; } } return0; } intmain() { SHOP*head; SHOP*newhead; head=buildlink(); showlink(head); newhead=revlink(head); showlink(newhead); showlink(head); printf("Deleteanode: "); charstr[50]; scanf("%s",str); inti; i=delnode(head,str); showlink(head); if(i==1) printf("Deletesuccessful! \n"); return0; } style="MARGIN: 0px;COLOR: rgb(102,102,102);LINE-HEIGHT: 150%"wrap="break-word"#include"stdio.h" #include"stdlib.h" intmyAtoi(char*s); voidmain() { inti; char*s=(char*)malloc(10*sizeof(char)); if(s==NULL){ printf("failtomallocs\n"); return; } while (1){ scanf("%s",s); if((*s)=='q'){ break; } i=myAtoi(s); printf("%d\n",i); } } intmyAtoi(char*s) { inti=0; intflag=0; if(s==NULL)return0; if(*s=='+'||*s=='-') { if(*s=='-'){ flag=1; } s++; } while(*s! ='\0'&&*s>='0'&&*s<='9'){ i=(int)(*s)-'0'+i*10; s++; } if(flag)i=-i; returni; }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 嵌入式 工程师 试题 经典