




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
华为c语言笔试题'-(HUAWEIClanguagetestquestions-)HUAWEIexamcollectionWhat'stheuseof1.static?(pleasespecifyatleasttwo.)inafunctionbody,avariablethatisdeclaredasstatickeepsitsvalueconstantduringthecallofthisfunction.withinamodule(butoutsidethefunction),avariabledeclaredstaticcanbeaccessedbythefunctionusedwithinthemodule,butnotaccessiblebyotherfunctionsoutsidethemodule.Itisalocalglobalvariable.withinamodule,astaticallydeclaredfunctioncanonlybecalledbyotherfunctionswithinthismodule.Thatis,thisfunctionis1imitedtousewithinthelocalscopeofthemodulethatdeclaresitwhatisthedifferencebetweenreferenceandpointer?referencesmustbeinitialized,pointersdonothaveto.afterreferenceinitializationcannotbechanged,thepointercanchangetheobjectthatitrefersto.thereisnoreferencetonullvalues,buttherearepointerstonullvalues.describethebasiccharacteristicsofreal-timesystemsPerformspecifictasksatagiventime,withreal-timeandreliability.arethereanydifferencesbetweenglobalandlocalvariablesinmemory?Ifso,whatisthedifference?Globalvariablesarestoredinstaticglobaldatasegments,whilelocalvariablesareonthestack.whatisabalancedtwoforktree?Theleftandrightsubtreesarebalancedtwoforkstrees,andtheabsolutevalueofthedifferencebetweentheleftandrightsubtreesisnotgreaterthan1.whatcausesthestackoverflowgenerally?Thereisnorecyclingofwasteresources.whatfunctionscannotbedeclaredasvirtualfunctions?Theconstructorfunctioncannotbedeclaredavirtualfunction.whatisthetimecomplexityofthebubblesortalgorithm?Thetimecomplexityis0(n2).writetheifstatementthatcomparesthefloatxwiththezerovalue.Whatkindofnetworkprotocoldoes10.Internetadopt?Whatistheprimaryhierarchyoftheprotocol?Tcp/ipprotocolThemainstructureisasfollows:applicationlayer/transportlayer/networklayer/datalinklayer/physicallayer.Whatprotocolsareusedfor11.InternetphysicaladdressandIPaddresstranslation?ARP(Address,Resolution,Protocol)(addressresolutionprotocol)Whatarethetwopartsoftheencodingofthe12.IPaddress?TheIPaddressconsistsoftwoparts,thenetworknumberandthehostnumber.However,youhavetousethesubnetmasktopressandthentodistinguishbetweennetworkbitsandwhichhostsarebits.13.,theuserinputM,Nvalue,from1toNstartcyclecount,counttoM,outputthevalueuntilalltheoutput.WritetheCprogram.Circularlinkedlist,withtheremainingoperationsdone14.cannotdoswitch().Theargumenttypeis:Theparametersofswitchcannotbereal.ShanghaiHUAWEIapointerontheproblemofprogrammingIntALnSize],whichhidesanumberof0,andtherestofthe0noninteger,writeafunctionintFunc(int*,A,int,nSize),sothatAmove0totheback,not0integersmovedtoThearrayisorderedinfrontandreturnsthesubscriptofthefirstelementintheoriginaldataof0.(asfaraspossiblewithoutusingtheauxiliaryspaceandconsideringtheefficiencyandtheexception),theannotationspecificationandthedesignideaaregivenHUAWEIwrittenquestionscontaininganswers[softwareengineeringquestions]Writeaprogramthatrequiresfunctions:findthecombinationof1,2,5,threenumbers,differentnumbers,andacombinationof100.Suchas:100,lisacombination,51plus19,5isacombination....PleasewriteinC++language.Answer:theeasiestwaytothinkaboutitis..:LetXbethenumberof1,yisthenumberof2,Zisthenumberof5,andnumberisthecombinationnumberNotethat0<=x<=100,0<=y<=50,0<=z=20,andsocanbeprogrammedas:Number=0;For(x=0;x<=100;x++)For(y=0;y<=50;y++)For(z=0;z<=20;z++)If((x+2*y+5*z)==100)Number++;Cout<<number<<endl;Theprogramabovecycles100*50*20times,TheefficiencyisreallytoolowInfact,thesubjectisaclearmathematicalproblem,notapurelyprogrammingone.Mysolutionisasfollows:Becausex+2y+5z=100Sox+2y=100-5z,andz<=20,x<=100,y<=50So(x+2y)<=100,and(x+5z)isevenForZcycles,thepossiblevaluesforXareasfollows:Z=0,x=100,98,96,...0Z=l,x=95,93,,1Z=2,x=90,88,…,0Z=3,x=85,83,,1Z=4,x=80,78,,0Z=19,x=5,3,1Z=20,x=0Therefore,anoddnumberoflessthan100oftheodd+90withinanevennumberof+1withinatotalnumberof+95oroddnumberswithin+5,Namely:(46+43)+(41+38)+(36+33)+(31+28)+(26+23)+(21+18)+(51+48)+(16+13)+(11+8)+(+1)+(6+3)?Evennumbers(including0)withinanevennumberofMcanberepresentedasm/2+l=(m+2)/2TheoddnumberwithinanoddnumberofMcanalsobeexpressedas(m+2)/2Therefore,thetotalnumberofcombinationscanbeprogrammedNumber=O;For(intm=0;m<=100;m+=5)Number+=(m+2)/2;Cout<<number<<endl;Thisprogramonlyneeds21cyclesandtwovariablestogettheanswer,muchmoreefficientthantheoneaboveTimessimplybecauseofsomesimplemathematicalanalysisThisprovesagain:computerprograms=datastructures+algorithms,andalgorithmsarethesouloftheprogram,askanyprojectWhensoftwareisimplemented,wemustselectsuchresourcesascurrentresourceconstraints,userrequirementsconstraints,anddevelopmenttimeconstraintsOptimalalgorithmunderfourkindsofconstraints.Andnevergetahand,andimmediatelyputtogetheraprogramwiththeeasiesttothinkofIt,snotthebehaviorofaprofessionalR&Dstaff.So,isthatoneoftheeasiestalgorithmsoutofthequestion?No,thisalgorithmcanbeusedtovalidatethenewalgorithmThecorrectnessofthedebuggingphase,whichisveryuseful.Inmanylargecompanies,suchasMicrosoft,thisapproachhasbeenadoptedInthetestingphase,someimportantprogramswhichneedgoodalgorithmareimplemented,andthegoodalgorithmisusedatthesametimeEasytothinkalgorithmstoverifythisprocedure,iftheresultsofthetwoalgorithmsareinconsistent(andmosteasilythoughtofbythealgorithm)Theproofiscorrect,thentheoptimizationalgorithmisoutoforderandneedstobemodified.Examplescanbeexpressedas:#ifdefDEBUGInt,simple();#endifInt,optimize();Inafunction:Result=optimize();ASSERT(result-simple());Thus,inthedebuggingphase,iftheresultsofthesimplealgorithmandtheoptimizationalgorithmareinconsistent,theassertionisasserted.Atthesametime,intheprocessThereleaseversionoftheorderdoesnotcontainthebulkysimple()function.AnylargeengineeringsoftwareneedstobedesignedinadvanceGooddebuggingmeans,andtheonementionedhereisausefulmethod.Astudent'sinformationis:name,studentnumber,gender,ageandotherinformation,usingalinkedlist,puttogethertheinformationofthesestudents,givenaage,inthelistisequaltotheagestudentinformationdeletestudentage.ttinclude"stdio.h"”ffincludeconio.hStructstu{Charname[20];Charsex;Intno;Intage;Structstu*next;}*linklist;Structstu*creatlist(intn)IInti;//histheheadnode,Pisthepreviousnode,andSisthecurrentnodeStruct,Stu,*h,*p,*s;H=(struct,Stu*)malloc(sizeof(struct,Stu));H->next=NULL;P=h;For(i=0;i<n;i++)S=(struct,Stu*)malloc(sizeof(struct,Stu));P->next=s;printf(“请输入信息的学生:姓名性别年龄不\n");scanf(“%s%c%d%d",S->名称->,和性别,和S-〉没有,&S->年龄);s=下一个null;P=s;)printf("创造成功!”);返回(h);)无效deletelist(structstu的int)!结构体;而(年龄)!=一个)P=s;下一个;)如果(=NULL)printf("记录是不存在的。”);其他的I下一个;printf("删除成功!”);))空显示(结构){下一个;当(S!=null)printf("%s%c%d%d\n",S-〉名称->性别的,S->不,S年龄);下一个;}}国际main(){结构体;年龄、年龄;printf(“请输入详细说明:长度:\n");scanf(“强d”,和N);S=creatlist(N);显示器(s);printf(“请输入年龄:\n");scanf(“断1”,年龄);deletelist(的时代);显示器(s);返回0;)2、实现一个函数,把一个字符串中的字符从小写转为大写。包括“stdio.h”包括“是的。”虚顶(字符,字符*)I因为(!=“0”;“++”,“++”){如果(*>=""&*<=Z)我们*S-32;其他的*美国二;*我们="0";国际main()(char*,*我们;char[20];printf(“请输入一个字符串:\n");scanf(“%s”,SS);S=SS;鞋面(S,我们);printf(“结果:\n%s\n”,美国);getchO;}随机输入一个数,判断它是不是对称数(回文数)(如不能用字符串库函数31211232145254)。****函数名称:对称性功能:判断一个数时候为回文数(12135653)输入:长整型的数输出:若为回文数返回值为1其他0xix xL»*1**1**L»xt»xL»xt»»lxxtz*1*xL»«Jxxl»«J>*£*xL»*1**1**1»«lx*1**1*«X*xlx«lxxlxxl*xL«*4x«lxxlx«lx «lx«lx «Jz«Jxxl*«lx*p»ZJ*ZJ*>p»*JX*p»ZJ*ZJ*>p» zjx *p» ZJ* zjx zjs »JSZJ**p» zj*>p»zjs*******/无符号char对称(长n)(长我,临时工;i=n;临时值=0;而(我)/不用出现长度问题,将数按高低位掉换温度=温度10+i%10;i=10;返回(温度=n);)方法一/*功能:判断字符串是否为回文数字实现:先将字符串转换为正整数,再将正整数逆序组合为新的正整数,两数相同则为回文数字输入:char*:待判断的字符串输出:返回:0:正确;1:待判断的字符串为空;2:待判断的字符串不为数字;3:4:待判断的字符串溢出字符串不为回文数字;无符号issymmetry(char*)(char*s;长的N=0;长n=0;长ntemp=0;判断输入是否为空/**/如果(0)返回1;将字符串转换为正整数/**/同时(*!“0”判断字符是否为数字/**/如果(p<0\"\I|*P'年\")返回2;Judgingwhetherapositiveintegeroverflow/**/If((*p-\'0\')>(4294967295-(nNumber*10))Return4;NNumber=(*p-\'0\')+(nNumber*10);P++;)/*digitalreversecombination,directlycopytheupstairsmastercode,nowonder,oh.N=nNumber;While(n)Judgingwhetherapositiveintegeroverflow/**/If((n%10)>(4294967295-(nTemp*10))Return3;NTemp=nTemp*10+n%10;N/=10;)Comparedwiththeoriginalnumber/reverseisequal.If(nNumber==nTemp)Return3;Return0;)Methodtwo/*Function:DetermineswhetherastringisapalindromenumberRealization:Firstwegetthelengthofthestring,andthencomparethecorrespondingbitcharactersofthestringinturnInput:Char*s:thestringtobejudgedOutput:nothingReturn:0:correct:1:thestringtobejudgednull;2:thestringtobejudgedisnotnumeric;3:stringisnotpalindromenumbersWasn*UnsignedIsSymmetry_2(char*s)Char*p=s;IntnLen=0;Inti=0;Shoulddeterminewhethertheinputisempty.If(*s=\'\\0\')Return1;Getthelengthofthestring/**/While(*p==\'\\0\'){Todeterminewhetheracharacterisdigital/**/If(*p<\'0\'*p>\'9\'||)Return2;NLen++;P++;)*lengthisodd,notforpalindromenumbers.If(nLen%2=0)Return4;/*lengthlisapalindromicnumber.If(nLen=1)Return0;Inordertocomparethesamecharacterscorresponding/**/P=s;I=nLen/2-1;While(I)(If(*(p+i)=*(p+nLen-i-1))Return3;I~~;)Return0;}Seekallprimenumbersof2〜2000.Haveenoughmemory,askforassoonaspossibleAnswer:Intfindvalue[2000]={2};Staticintfind=l;Booladjust(intvalue)Assert(value>=2);If(value==2)returntrue;For(inti=0;i<=find;i++)If(value%findvalue[i]==0)Returnfalse;Findvalue[find++];Returntrue;HUAWErslastthreebigquestionsA,B,C,Dfourprocesses,Awritedatatothebuf,B,C,D,readdatatothebuf,WhenAfinisheswriting,andB,C,andDarereadonce,Acanwriteagain.ImplementedwithP,Voperations.willone-waylistreverse,suchasABCDintoDCBA,canonlysearchlistonce.,twoforktreetwochiIdrenchangepositions,thatis,leftturnright,leftturnright.YoucantuseapassHUAWEItestquestions:2007.03.31HUAWEIwrittenexaminationquestionsoneortwoTosayafew:(feelHUAWEI,butso,althoughmypointsarenothigh,becausealotofquestionsIdotohimisreallyinsultingmyIQ)38outof3cowsrunfastest,usingasitethatprovidesonly6racesatatime,requiringthefastestmethod.Igaveoneofthemoststupidanswers,becauseIfoundtherewere38peopleinawrittentest,andIdidn'tknowwhatitmeantTheeffectisasfollows:thestaffknowtheboss'sage,don'tknowhisdaughter,sage,thebossof3daughtersagesumis13,multipliedbythebossage,andonlyadaughterolderthan5,andthe4age?(therearelotsofanswersontheInternet!)Theoriginaltitleisacontestofmathematicalmodelingcontestforcollegestudentsbefore2002,Thatis,astudentintherainfromthedormitorytothecafeteriatoeat,200metersdistance,askiswalkinglessrainorrunningless?Thisquestionsimplifiesmostoftheassumptions.ThereareonlyafewquestionsleftforyoutosolveHUAWErslatesttestquestionsandtheiranalysisTheoutputproblemof1.printfPrintf total);//this,is,rightPrintf(total);//this,is,wrongPrintf("hello");//but,this,is,rightthelengthofanintegertypeChar1subsections,8bitsUnsignedshort[int][signed]shortintShort2bytes,16bits[signed]intUnsignedintTypeintinVCis4subsections,32bits,or16bits,2bytesLong[int]Unsignedlong[int]Typelongis32bits,4bytesFloat32,4Double64,8Longdouble128,16Char8,abytethatholdstheactualcharacteroftheASCIIcodeFindoutthemistakesandcorrectthemChar*my_cpy(char*,SRC,int,len){Chardest[1024];Memcpy(DeST,SRC,len);Returndest;Isthereaproblemwiththefunctionabove?Ifitindicateswhereitis,ifnot,afunctionfunctiondescriptionisgiven.Answer:ArraysshouldbeinitializedMemcpydoesnotdeterminewhethertocrossthebounds,sobeforecalling,youshoulddeterminewhetherornottheboundsarecrossedRestshouldnotbereturnedbecausethearrayisappliedinsidethefunction,sothefunctiondisappearsaftertheendofthefunction,andthepointerbecomesawildpointer,pointingtoanillegaladdressThelastoneishiddenChar*memcpy(char,*dest,const,char,*src,int,len)Char*pDest=(char*)dest;Char*pSrc=(char*)src;Intpos;For(pos=0;pos<len;pos++)PDest[pos]=pSrc[pos];Return(char*)pDest;Thereisnoproblemtojudgewhethertheillegalpointerassert(dest=NULLSRC||!!=NULL);conditionsforFLASEdisplayDonotcallotherfunctions,writeamemcpyfunction,functionprototypeforVoid*memcpy(void,*dest,void,*src,sizet,length);-gooduseofassertions一/*memcpy-copydoesnotoverlapthememoryblock.Voidmemcpy(void*,pvTo,void*,pvFrom,sizet,size)IVoid*pbTo=(byte*)pvTo;Void*pbFrom=(byte*)pvFrom;ASSERT(pvTo!=NULL&&pvFrom!=NULL);/*memoryblockoverlap?Iftheoverlap,theuseofmemmove*/ASSERT(pbTo>=pbFrom+sizepbFrom>=pbTo+size||);While(size->0)*pbTo++==*pbFrom++;Return(pvTo);)AndCommonfunctionprogramming:Char*strcpy(char,*strDest,const,char,*strSrc)iASSERT(strDest!=NULL&&strSrc!=NULL);Char*addr=strDest;While(*strDest++=*strSrc++)NULL;//NULLcanbeomitted,butitismoreconducivetocompilerdiscoveryerrorsReturnaddr;Void*memcpy(void,*dest,const,void,*src,int,count)ASSERT(dest!=NULL&&SRC!=NULL);For(inti=0;i<
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- T-ZJCX 0045-2024 食用菌干制品
- T-ZGZS 0411-2024 T-CCPITCSC 150-2024 绿色会展废弃物管理规范
- T-ZMDS 10024-2024 手术导航设备配准技术要求及试验方法
- 2025年度高端办公空间无偿租赁合作协议
- 2025年度能源企业质押贷款担保合同
- 二零二五年度企业办公用品定制化采购合同
- 医药公司二零二五年度员工商业秘密保密协议及保密技术支持服务协议
- 2025年度村办公室装修与农村电商市场拓展合作合同
- 二零二五年度酒店加盟店经营管理合作协议
- 2025年度物流园区开发物业移交与仓储物流服务协议
- 五年级下册英语作文训练-外研版(三起)
- 7.2.1 圆柱(课件含动画演示)-【中职】高一数学(高教版2021基础模块下册)
- 《义务教育数学课程标准(2022年版)》测试题+答案
- 便利店门店运营手册
- 江苏省南通市海安中学2025届高一下生物期末综合测试试题含解析
- 《行政伦理学教程(第四版)》课件 第1、2章 行政伦理的基本观念、行政伦理学的思想资源
- 拆除工程施工拆除进度安排
- 绝缘技术监督上岗员:厂用电设备技术监督考试资料一
- 卫生监督村医培训课件
- 动物的感觉器官
- 猎头项目方案
评论
0/150
提交评论