1 / 35
文档名称:

2020年度嵌入式软件工程师笔试题.doc

格式:doc   大小:423KB   页数:35页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

2020年度嵌入式软件工程师笔试题.doc

上传人:梅花书斋 2019/12/10 文件大小:423 KB

下载得到文件列表

2020年度嵌入式软件工程师笔试题.doc

相关文档

文档介绍

文档介绍:1、将一个字符串逆序2、将一个链表逆序3、计算一个字节里(byte)里面有多少bit被置14、搜索给定的字节(byte)5、在一个字符串中找到可能的最长的子字符串6、字符串转换为整数7、整数转换为字符串/**题目:将一个字符串逆序*完成时间:.*版权归刘志强所有*描述:写本程序的目的是希望练一下手,希望下午去面试能成功,不希望国庆节之后再去找工作拉!*/#include<iostream>usingnamespacestd;//#defineNULL((void*)0)char*mystrrev(char*constdest,constchar*constsrc){if(dest==NULL&&src==NULL)  returnNULL;char*addr=dest;intval_len=strlen(src);dest[val_len]='\0';inti;for(i=0;i<val_len;i++){  *(dest+i)=*(src+val_len-i-1);  }returnaddr;}main(){char*str="asdfa";char*str1=NULL;str1=(char*)malloc(20);if(str1==NULL)  cout<<"mallocfailed";cout<<mystrrev(str1,str);free(str1);str1=NULL;//杜绝野指针}p=head;q=p->next;while(q!=NULL){temp=q->next;q->next=p;p=q;q=temp;}这样增加个辅助的指针就行乐。ok通过编译的代码:#include<>#include<>#include<>typedefstructList{intdata;structList*next;}List;List*list_create(void){structList*head,*tail,*p;inte;head=(List*)malloc(sizeof(List));tail=head;printf("\nListCreate,inputnumbers(endof0):");scanf("%d",&e);while(e){p=(List*)malloc(sizeof(List));p->data=e;tail->next=p;tail=p;scanf("%d",&e);}tail->next=NULL;returnhead;}List*list_reverse(List*head){List*p,*q,*r;p=head;q=p->next;while(q!=NULL){r=q->next;q->next=p;p=q;q=r;}head->next=NULL;head=p;returnhead;}voidmain(void){structList*head,*p;intd;head=list_create();printf("\n");for(p=head->next;p;p=p->next)printf("--%d--",p->data);head=list_reverse(head);printf("\n");for(p=head;p->next;p=p->next)printf("--%d--",p->data);}      编写函数数N个BYTE的数据中有多少位是1。解:此题按步骤解:先定位到某一个BYTE数据;再计算其中有多少个1。叠加得解。#incluede<iostream>#defineN10//定义BYTE类型别名#ifndefBYTEtypedefunsignedcharBYTE;#b(BYTEb[],intn){intcount=0;intbi,bj;=1,tt;//历遍到第bi个BYTE数据for(bi=0;bi<n;bi++){//计算该BYTE的8个bit中有多少个1tt=b[bi];     for(bj=0;bj<8;bj++){      //与1相与或模2结果是否是1?测试当前bit是否为1      //if(tt%2==1)     if(()==1){        count++;      }      //右移一位或除以2,效果相同//tt=tt>>1;tt=tt/2;}}returncount;}//测试intmain(){BYTEb[10]={3,3,3,11,1,1,1,1,1,1};cout<<comb(b,N)<<endl;return0;}1。编写一个C函数,该函数在一个字符串中找到可能的最长的子字符串,且该字符串是由同一字符组成的。char*search(char*cpSource,charch){char*cpTemp=NULL,*