华为校园招聘电子科大上机题目[精选]

上传人:u**** 文档编号:186384249 上传时间:2021-07-16 格式:DOC 页数:6 大小:23KB
返回 下载 相关 举报
华为校园招聘电子科大上机题目[精选]_第1页
第1页 / 共6页
华为校园招聘电子科大上机题目[精选]_第2页
第2页 / 共6页
华为校园招聘电子科大上机题目[精选]_第3页
第3页 / 共6页
华为校园招聘电子科大上机题目[精选]_第4页
第4页 / 共6页
华为校园招聘电子科大上机题目[精选]_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《华为校园招聘电子科大上机题目[精选]》由会员分享,可在线阅读,更多相关《华为校园招聘电子科大上机题目[精选](6页珍藏版)》请在金锄头文库上搜索。

1、华为2014校园延聘的机试题目跟的完好一样。一、题目描画60分:通过键盘输出一串小写字母(az)形成的字符串。请编写一个字符串过滤次序,假定字符串中出现多个一样的字符,将非首次出现的字符过滤丢掉。比如字符串“abacacde过滤结果为“abcde。要务虚现函数:voidstringFilter(constchar*pInputStr,longlInputLen,char*pOutputStr);【输出】pInputStr:输出字符串lInputLen:输出字符串长度【输出】pOutputStr:输出字符串,空间已经开辟好,与输出字符串等长;【留心】只需务虚现该函数功能算法,中间不需要有任何IO

2、的输出输出比如输出:“deefd输出:“def输出:“afafafaf输出:“af输出:“pppppppp输出:“pmain函数已经隐藏,这里保管给用户的测试出口,在这里测试你的完成函数,可以调用printf打印输出当前你可以应用其他方法测试,只需保证最终次序能精确实行即可,该函数完成可以任意修改,但是不要修改函数原型。肯定要保证编译运行不受阻碍。二、题目描画40分:通过键盘输出一串小写字母(az)形成的字符串。请编写一个字符串压缩次序,将字符串中连续出席的重复字母停顿压缩,并输出压缩后的字符串。压缩规那么:1、仅压缩连续重复出现的字符。比如字符串abcbc由于无连续重复字符,压缩后的字符串仍

3、然abcbc。2、压缩字段的格式为字符重复的次数+字符。比如:字符串xxxyyyyyyz压缩后就成为3x6yz。要务虚现函数:voidstringZip(constchar*pInputStr,longlInputLen,char*pOutputStr);【输出】pInputStr:输出字符串lInputLen:输出字符串长度【输出】pOutputStr:输出字符串,空间已经开辟好,与输出字符串等长;【留心】只需务虚现该函数功能算法,中间不需要有任何IO的输出输出比如输出:“cccddecc输出:“3c2de2c输出:“adef输出:“adef输出:“pppppppp输出:“8p三、题目描画5

4、0分:通过键盘输出100以内正整数的加、减运算式,请编写一个次序输出运算结果字符串。输出字符串的格式为:“把持数1运算符把持数2,“把持数与“运算符之间以一个空格隔开。补偿说明:1、把持数为正整数,不需要考虑打算结果溢出的情况。2、假定输出算式格式差错,输出结果为“0。要务虚现函数:voidarithmetic(constchar*pInputStr,longlInputLen,char*pOutputStr);【输出】pInputStr:输出字符串lInputLen:输出字符串长度【输出】pOutputStr:输出字符串,空间已经开辟好,与输出字符串等长;【留心】只需务虚现该函数功能算法,中

5、间不需要有任何IO的输出输出比如输出:“4+7输出:“11输出:“4-7输出:“-3输出:“9+7输出:“0注:格式差错cppviewplaincopyprint?/华为第一题19:19-19:3617分钟#include#includeusingnamespacestd;boolg_flag26;voidstringFilter(constchar*pInputStr,longlInputLen,char*pOutputStr)assert(pInputStr!=NULL);inti=0;if(pInputStr=NULL|lInputLen=1)return;constchar*p=pIn

6、putStr;while(*p!=0)if(g_flag(*p-a)p+;elsepOutputStri+=*p;g_flag*p-a=1;p+;pOutputStri=0;intmain()memset(g_flag,0,sizeof(g_flag);charinput=abacacde;char*output=newcharstrlen(input)+1;stringFilter(input,strlen(input),output);coutoutputendl;deleteoutput;return0;/华为第一题c完成#include#include#include#include/

7、boolg_flag26;voidstringFilter(constchar*pInputStr,longlInputLen,char*pOutputStr)charflag26;memset(flag,0,26);assert(pInputStr!=NULL&lInputLen!=0);inti=0;constchar*p=pInputStr;while(*p!=0)if(flag(*p-a)p+;elsepOutputStri+=*p;flag*p-a=1;p+;pOutputStri=0;intmain()charinput=a;charoutputsizeof(input);prin

8、tf(%dn,strlen(input);stringFilter(input,strlen(input),output);printf(result:%sn,output);return0;cppviewplaincopyprint?/华为第二题19:40-20:10中间耽误3分钟#include#includeusingnamespacestd;voidstringZip(constchar*pInputStr,longlInputLen,char*pOutputStr)constchar*p=pInputStr;intnum=1;inti=0;p+;while(*p!=NULL)whil

9、e(*p=*(p-1)&*p!=NULL)num+;p+;if(num1)intsize=0;inttemp=num;while(num)/打算位数size+;num/=10;num=1;for(intj=size;j0;j-)pOutputStri+j-1=0+temp%10;temp/=10;i+=size;pOutputStri+=*(p-1);p+;elsepOutputStri+=*(p-1);p+;pOutputStri=0;intmain()charinput=cccddecc;char*output=newcharstrlen(input)+1;stringZip(input,

10、strlen(input),output);coutoutputendl;return0;/华为第三题20:29-20:40#includeusingnamespacestd;voidarithmetic(constchar*pInputStr,longlInputLen,char*pOutputStr)constchar*input=pInputStr;char*output=pOutputStr;intsum=0;intoperator1=0;intoperator2=0;char*temp=newchar5;char*ope=temp;while(*input!=)/获得把持数1sum=

11、sum*10+(*input+-0);input+;operator1=sum;sum=0;while(*input!=)*temp+=*input+;input+;*temp=0;if(strlen(ope)1)*output+=0;*output=0;return;while(*input!=0)/获得把持数1sum=sum*10+(*input+-0);operator2=sum;sum=0;switch(*ope)case+:itoa(operator1+operator2,pOutputStr,10);break;case-:itoa(operator1-operator2,pOutputStr,10);break;default:*output+=0;*output=0;return;intmain()charinput=4-7;charoutput=;arithmetic(input,strlen(input),output);coutoutputendl;return0;

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

当前位置:首页 > 大杂烩/其它

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