《华为c语言笔试题-(HUAWEIClanguagetestquestions-).docx》由会员分享,可在线阅读,更多相关《华为c语言笔试题-(HUAWEIClanguagetestquestions-).docx(38页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、华为 c 语言笔试题-(HUAWEI C language test questions -)HUAWEI exam collectionWhats the use of 1. static?(please specify at least two.)1) in a function body, a variable that is declared as static keeps its value constant during the call of this function.2) within a module (but outside the function), a variab
2、le declared static can be accessed by the function used within the module, but not accessible by other functions outside the module. It is a local global variable.3) within a module, a statically declared function can only be called by other functions within this module. That is, this function is 1
3、imited to use within the local scope of the module that declares it2. what is the difference between reference and pointer?1) references must be initialized, pointers do not have to.2) after reference initialization cannot be changed, the pointer can change the object that it refers to.3) there is n
4、o reference to null values, but there are pointers to null values.3. describe the basic characteristics of real-time systemsPerform specific tasks at a given time, with real-time andreliability.4. are there any differences between global and local variables in memory? If so, what is the difference?G
5、lobal variables are stored in static global data segments, while local variables are on the stack.5. what is a balanced two fork tree?The left and right subtrees are balanced two forks trees, and the absolute value of the difference between the left and right subtrees is not greater than 1.6. what c
6、auses the stack overflow generally?There is no recycling of waste resources.7. what functions cannot be declared as virtual functions?The constructor function cannot be declared a virtual function.8. what is the time complexity of the bubble sort algorithm?The time complexity is 0(n 2).9. write the
7、if statement that compares the float x with the zero value.What kind of network protocol does 10. Internet adopt? What is the primary hierarchy of the protocol?Tcp/ip protocolThe main structure is as follows: application layer / transport layer / network layer / data link layer / physical layer.What
8、 protocols are used for 11. Internet physical address and IP address translation?ARP (Address, Resolution, Protocol)(address resolution protocol)What are the two parts of the encoding of the 12. IP address?The IP address consists of two parts, the network number and the host number. However, you hav
9、e to use the subnet mask to press and then to distinguish between network bits and which hosts are bits.13., the user input M, N value, from 1 to N start cycle count, count to M, output the value until all the output. Write the C program.Circular linked list, with the remaining operations done14. ca
10、nnot do switch (). The argument type is:The parameters of switch cannot be real.Shanghai HUAWEI a pointer on the problem of programmingInt ALnSize, which hides a number of 0, and the rest of the 0 non integer, write a function int Func (int*, A, int, nSize), so that A move 0 to the back, not 0 integ
11、ers moved toThe array is ordered in front and returns the subscript of the first element in the original data of 0.(as far as possible without using the auxiliary space and considering the efficiency and the exception), the annotation specification and the design idea are givenHUAWEI written questio
12、ns containing answers software engineering questionsWrite a program that requires functions: find the combination of 1,2,5, three numbers, different numbers, and a combination of 100.Such as:100, lisa combination,51 plus 19,5 is a combination. Please write in C+ language.Answer: the easiest way to t
13、hink about it is.:Let X be the number of 1, y is the number of 2, Z is the number of 5, and number is the combination numberNote that 0=x=100,0=y=50,0=z=20, and so can be programmed as: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+;Coutnumberendl;The pr
14、ogram above cycles 100*50*20 times,The efficiency is really too lowIn fact, the subject is a clear mathematical problem, not a purely programming one. My solution is as follows:Because x+2y+5z=100So x+2y=100-5z, and z=20, x=100, y=50So (x+2y)=100, and (x+5z) is evenFor Z cycles, the possible values
15、for X are as follows: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, an odd number of less than 100 of the odd +90 within an even number of +1 within a total number of +95 or odd numbers within +5,Namely:(46+43)+(41+38)+(36+33)+(31+28)+(26
16、+23)+(21+18)+(51+48)+(16+13)+(11+8)+(+1)+(6+3)?Even numbers (including 0) within an even number of M can be represented as m/2+l=(m+2)/2The odd number within an odd number of M can also be expressed as (m+2)/2Therefore, the total number of combinations can be programmedNumber=O;For (int m=0; m=100;
17、m+=5)Number+=(m+2)/2;Coutnumbernext = NULL;P=h;For (i=0; inext = s;printf (“请输入信息的学生:姓名性别年龄不n);scanf (“%s %c %d %d,S -名称-,和性别,和 S -没有,& S-年龄);s =下一个 null;P = s;)printf (创造成功!”);返回(h);)无效 deletelist (struct stu 的 int)!结构体;而(年龄)!=一个)P = s;下一个;)如果(=NULL)printf (记录是不存在的。”);其他的I下一个;printf (删除成功!”);)空显示(结
18、构)下一个;当(S!= null) printf (s %c %d %dn,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”;“+”,“+”)如果(*=&* xL*
19、1*1*1lx *1*1*X* xlxlxxlx xl*xL*4xlx xlx lxlx lxJz Jx xl*lx*p ZJ* ZJ*p*JX *p ZJ* ZJ*pzjx*pZJ*zjxzjsJS ZJ*pzj*p zjs*/无符号char对称(长n)(长我,临时工;i=n;临时值=0;而(我)/不用出现长度问题,将数按高低位掉换温度=温度10+ i %10;i =10;返回(温度=n);)方法一/*功能:判断字符串是否为回文数字实现:先将字符串转换为正整数,再将正整数逆序组合为新的正整数,两数相同则为回文数字输入:char *:待判断的字符串输出:返回:0:正确;1:待判断的字符串为空;
20、2:待判断的字符串不为数字;3:4:待判断的字符串溢出字符串不为回文数字;无符号 issymmetry (char *)(char * s;长的N =0;长 n=0;长 ntemp =0;判断输入是否为空/*/如果(0)返回1;将字符串转换为正整数/*/同时(*!“0”判断字符是否为数字/*/如果(p(4294967295-(nNumber*10)Return 4;NNumber =(*p-0)+(nNumber *10);P+;)/* digital reverse combination, directly copy the upstairs master code, no wonder,
21、 oh.N = nNumber;While (n)Judging whether a positive integer overflow /*/If (n%10)(4294967295-(nTemp*10)Return 3;NTemp = nTemp*10+ n%10;N /=10;)Compared with the original number / reverse is equal.If (nNumber = nTemp)Return 3;Return 0;)Method two/*Function:Determines whether a string is a palindrome
22、numberRealization:First we get the length of the string, and then compare the corresponding bit characters of the string in turnInput:Char *s: the string to be judgedOutput:nothingReturn:0: correct:1: the string to be judged null;2: the string to be judged is not numeric;3: string is not palindrome
23、numbersWasn *Unsigned IsSymmetry_2(char *s)Char *p = s;Int nLen =0;Int i =0;Should determine whether the input is empty.If (*s =0)Return 1;Get the length of the string /*/While (*p =0)To determine whether a character is digital /*/If (*p9|)Return 2;NLen+;P+;)* length is odd, not for palindrome numbe
24、rs.If (nLen%2=0)Return 4;/* length lisa palindromic number.If (nLen =1)Return 0;In order to compare the same characters corresponding /*/P = s;I = nLen/2-1;While (I)(If (*(p+i)=*(p+nLen-i-1)Return 3;I;)Return 0;Seek all prime numbers of 22000. Have enough memory, ask for as soon as possibleAnswer:In
25、t findvalue2000=2;Static int find=l;Bool adjust (int value)Assert (value=2);If (value=2) return true;For (int i=0; i=find; i+)If (value%findvaluei=0)Return false;Findvaluef ind+;Return true;HUAWEr s last three big questions1. A, B, C, D four processes, A write data to the buf, B, C, D, read data to
26、the buf,When A finishes writing, and B, C, and D are read once, A can write again. Implemented with P, V operations.2. will one-way list reverse, such as ABCD into DCBA, can only search list once.3. , two fork tree two chiIdren change positions, that is, left turn right, left turn right. You can t u
27、se a passHUAWEI test questions:2007.03.31 HUAWEI written examination questions one or twoTo say a few:(feel HUAWEI, but so, although my points are not high, because a lot of questions I do to him is really insulting my IQ)1. 38 out of 3 cows run fastest, using a site that provides only 6 races at a
28、time, requiring the fastest method. I gave one of the most stupid answers, because I found there were 38 people in a written test, and I didnt know what it meant2. The effect is as follows: the staff know the boss s age, dont know his daughter,s age, the boss of 3 daughters age sum is 13, multiplied
29、 by the boss age, and only a daughter older than 5, and the 4 age?(there are lots of answers on the Internet!)3. The original title is a contest of mathematical modeling contest for college students before 2002,That is, a student in the rain from the dormitory to the cafeteria to eat,200 meters dist
30、ance, ask is walking less rain or running less? This question simplifies most of the assumptions. There are only a few questions left for you to solveHUAWEr s latest test questions and their analysisThe output problem of 1. printfPrintftotal);/this, is, rightPrintf (total);/this, is, wrongPrintf (he
31、llo);/but, this, is, right2. the length of an integer typeChar 1 subsections,8 bitsUnsigned short intsigned short intShort 2 bytes,16 bitssigned intUnsigned intType int in VC is 4 subsections,32 bits, or 16 bits,2 bytesLong intUnsigned long intType long is 32 bits,4 bytesFloat 32,4Double 64,8Long do
32、uble 128,16Char 8, a byte that holds the actual character of the ASCII code3. Find out the mistakes and correct themChar *my_cpy (char*, SRC, int, len)Char dest1024;Memcpy (DeST, SRC, len);Return dest;Is there a problem with the function above? If it indicates where it is, if not, a function functio
33、n description is given.Answer:1. Arrays should be initialized2. Memcpy does not determine whether to cross the bounds, so before calling, you should determine whether or not the bounds are crossed3. Rest should not be returned because the array is applied inside the function, so the function disappe
34、ars after the end of the function, and the pointer becomes a wild pointer, pointing to an illegal addressThe last one is hiddenChar *memcpy (char,*dest, const, char,*src, int, len)Char* pDest =(char*) dest;Char* pSrc =(char*) src;Int pos;For (pos=0; pos=pbFrom+size pbFrom=pbTo+size |);While (size-0)
35、*pbTo+=*pbFrom+;Return (pvTo);)AndCommon function programming:Char *strcpy (char,*strDest, const, char,*strSrc)iASSERT (strDest!= NULL & strSrc!= NULL);Char *addr = strDest;While (*strDest+=*strSrc+)NULL;/NULL can be omitted, but it is more conducive to compiler discovery errorsReturn addr;Void *memcpy (void,*dest, const, void,*src, int, count)ASSERT (dest!= NULL & SRC!= NULL);For (int i=0; i cout; i+)