应聘华为软件的上机试题及部分答案

上传人:飞*** 文档编号:3853701 上传时间:2017-08-12 格式:DOC 页数:25 大小:135KB
返回 下载 相关 举报
应聘华为软件的上机试题及部分答案_第1页
第1页 / 共25页
应聘华为软件的上机试题及部分答案_第2页
第2页 / 共25页
应聘华为软件的上机试题及部分答案_第3页
第3页 / 共25页
应聘华为软件的上机试题及部分答案_第4页
第4页 / 共25页
应聘华为软件的上机试题及部分答案_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《应聘华为软件的上机试题及部分答案》由会员分享,可在线阅读,更多相关《应聘华为软件的上机试题及部分答案(25页珍藏版)》请在金锄头文库上搜索。

1、1,判断电话号码是否合法:/要注意情况包含,有可能会同时出现几种不好的情况,要按照顺序输出错误。不能同时输出好几种错误,应该是这样包含:先判断长度是否符合,再判断是否以 86 打头,再判断有无其他字符int fun(char num) char *p=num;int n=strlen(num);if(n=13)if(*p=8&*(p+1)=6)while(*p!=0)if(*p=0&*p=0&j=0;i-,j-)if(arry1i!=arry2j)k+;return k;int main()int num1=1,3,5;int num2=77,21,1,3,5;int k=f(3,num1,5

2、,num2);cout=0&ai s1;for(int i=0;i=0&ai s2;for(int i=len;iaj)temp=ai;ai=aj;aj=temp;void test(int a) int *b=new int5;int k=1;for(int i=0;i bbj) csub = bbj;+sub;+j;else if(aai = bbj) +i;+j; for(; i next;while(p2)p3=p2-next;p2-next=p1;p1=p2;p2=p3;head-next=NULL;head=p1;return head;8、 将一个字符串的元音字母复制到另一个字符

3、串,并排序(30 分)问题描述:有一字符串,里面可能包含英文字母(大写、小写)、数字、特殊字符,现在需要实现一函数,将此字符串中的元音字母挑选出来,存入另一个字符串中,并对字符串中的字母进行从小到大的排序(小写的元音字母在前,大写的元音字母在后,依次有序)。说明:1、 元音字母是 a,e,i,o,u,A,E,I,O,U。 2、 筛选出来的元音字母,不需要剔重;最终输出的字符串,小写元音字母排在前面,大写元音字母排在后面,依次有序。要求实现函数:void sortVowel (char* input, char* output);using namespace std;void fun(char

4、 a,char s) /提取元音字母,放入数组 int i=0,n=0;while(ai!=0)if(ai=a|ai=e|ai=i|ai=o|ai=u)sn+=ai;else if(ai=A|ai=E|ai=I|ai=O|ai=U)sn+=ai;i+;char temp; /将数组排序for(int i=0;isj+1)temp=sj;sj=sj+1;sj+1=temp;int k=0; /定位大写字母的最后位置while(sk=A&sk=0&stri=0&str171900&year0&monthinputj+1)temp=inputj;inputj=inputj+1;inputj+1=te

5、mp;int k=0;i=0;j=n-1;while(i= 50且 *(task+pj+1)temp = pj;pj = pj+1;pj+1 = temp; /此处是排下标for(j=0;j=50 & *(task+pj)k) /创建单链表s=new node1;s-data=k;p-next=s;p=s;head=head-next; /开始的的时候head是表头节点,现在是第一个节点p-next=NULL;return head;node *creat()node *head,*p,*s;head=new node1;p=head;int k,cyc=1;while(cyc)coutk;i

6、f(k!=0)s=new node1;s-data=k;p-next=s;p=s;elsecoutnext;p-next=NULL;return head;node *reverse(node *head) node *p1,*p2,*p3;p1=head;p2=head-next;while(p2)p3=p2-next;p2-next=p1;p1=p2;p2=p3;head-next=NULL;head=p1;return head;node *del(node *head,int num) node *p,*s;p=head;while(p-data!=num&p-next!=NULL)s

7、=p;p=p-next;if(p-data=num)if(p=head)head=p-next;delete p;elses-next=p-next;delete p;elsecoutdata=num;while(p-datanext!=NULL)s=p;p=p-next;if(numdata)if(p=head)t-next=p;head=s;else t-next=p;s-next=t;else /把插入点定位在了链尾p-next=t;t-next=NULL;return head;node *sort(node* head) node *p; int temp;int n=sizeof(

8、head)/sizeof(node);if(head=NULL&head-next=NULL)return head;p=head;for(int i=0;idatap-next-data) temp=p-data;p-data=p-next-data;p-next-data=temp; return head;node *sort(node *head)node *p;int temp;int n;n=length(head);if(head=NULL&head-next=NULL)return head;for(int i=0;inext!=NULL)if(p-datap-next-dat

9、a)temp=p-data;p-data=p-next-data;p-next-data=temp;p=p-next;coutdata=num;p-next=top;top=p;void pop(node &top) node *p=top;int n=top-data;top=top-next;couti;j-)if(sjsj+1) b=1;temp=sj;sj=sj+1;sj+1=temp;i+;18、扫描数组,求出最大的增量长度:int main() int a=7,2,3,4,5,6,8;int n=7;int max=1,len=1;for(int i=1;i=ai-1) len+;

10、continue; /跳出本次循环,继续以下的部分if(max=i;j-) num=0;for( k=i;k=0&xaj;j-)aj+1=aj; aj+1=x;21、提取字符串中的数字:在字符串ab00cd+123fght456-253.005fgh中提取的字符是0,123,456,253,5。void fun( char str, int outArray) char *p=str;int count=0,value=0;while(*p!=0)if(*p=0&*p=0&*p0)stri=num%10+0;num=num/10;i+;i-;while(i=0)tempj+=stri-;tem

11、pj=0;coutN; /定义输入的行数getchar(); /输入的N行字符for(int i=0;i=0&j=0)resultn+=(pi-0)+(qj-0)+k)%10+0;k=(pi-0)+(qj-0)/10;i-;j-;while(i=0)resultn+=(pi-0)+k)%10+0;k=(pi-0)+k)/10;i-; while(j0)resultn+=(qj-0)+k)%10+0;k=(qj-0)+k)/10;i-;if(k=1)resultn+=1; /如果是两个负数相加 ,加上resultn+=-;resultn=0;25、求字符串中最大的回文长度:void fun(ch

12、ar a)int len=strlen(a);int i=0,j=len-1,len2=0; /len2是回文的一半长度char *p,*q;int max=0,pos1=0,pos2=0;for(i=0;ii;j-) p=&ai;q=&aj;while(pnum)p=new node1;p-data=num;p-next=NULL;q-next=p;q=p;return head;void reverse(node *head)node *p1,*p2,*p3;p1=*head;p2=p1-next;while(p2)p3=p2-next;p2-next=p1;p1=p2;p2=p3;(*head)-next=NULL;*head=p1;while(!(*head)-next=NULL)coutdatanext;void insert(node *head)node *p=head;while(p-data=num)p+;int main() node *head;head=new node1;head=creat();reverse(&head);return 0;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 资格认证/考试 > 医师/药师资格考试

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号