30130413 腾讯笔试

题目及答案参考:地址

为什么腾讯笔试的时间是10:30到12:30?难道腾讯人事部认为计算机的学生都是3点睡觉,9点起床,13点吃饭的吗?做了半个小时的题,就饿了;而且刚开始发卷子的时候,那卷子的模样,我是有多么熟悉啊:长长的,白白的,分明就是当年血战的高考卷子模样啊,一瞬间心血沸腾。拿到卷子后,就有点晕了,我是真的在编程啊,可是我怎么对题目就不知道如何下手呢?感觉题目就像是这样的:我们每天都在吃饭,然后问我们当拿筷子的时候,手握在离筷子尾部多长的位置?此时此刻,我真想找双筷子来我一下,谁吃饭的时候会思考会留意这个问题呢?我饿了,我要吃饭,我为什么要考虑吃饭的超级细节东西?我写程序,写程序只是个工具,我需要我的数据结果就ok了,我为什么要考虑一个无符号字符变量转换成有符号字符变量时候是什么模样?我突然意识到了我平常的训练目的和腾讯的考试目的差异是有多么的大:我是以解决问题为目的而使用工具,腾讯希望找到的是一个会熟练使用工具的能工巧匠。很遗憾的是我不是一个能工巧匠,在此向腾讯的码畜,码农,码工,码管等各级码人致敬!

言归正传,每次考试都要有所收获,都要吸取教训,我这次考试如同前几次考试一样,深深地意识到了本科不是计算机专业的各项劣势,要知道在一个和计算机沾一点点边的数学系泡四年,和在计算机专业泡四年,差别还是很大的。操作系统方面是我严重的缺陷,数据类型转换也很无语。这次投的是测试开发工程师,我压根都不知道这是干嘛的。。。很囧

1 基本数据类型转换

1)解决有符号和无符号的问题。 对于字符类型和整型来说, Assuming the size of type is k, if one unsigned data type a  is converted to the signed one b ,when a is larger than 2^(k-1), b is equal to a-2^(k)+1; otherwise, b is equal to a. If one signed data type b is converted to the unsigned one a,  when b is less than 0, a is equal to b+2^k. We have to understand that the changing of "signed" aims to  change the range of number presented by the k bits, but also maintain the same meaning as much as possible. Generally, the highest bit is the signal, if this highest bit is explained  as unsignal, so the range of number can be expanded. Noted that when the changing of "signed" happened, the explaination of meaning is changed , but the real bits do not change.

2) 类型转换。if there are converation between two different data types having different size, we have to handle the transfomation. First, if we converted a long data type to a short data type, we truncate the long data bits based on the size of short data type. Assuming we have to truncate1 Bytes from the 4 Bytes(0xff fe  fd  f7), which Bytes do we obtain? the left ,the most right? or the other.  This is decided by the big-endain storage or the little-endain storage. If it is the former, we get ff; If it is the latter, we get f7. Second, if we convert a short data type to a long data type, it is not as easy as filling enough 0 to the vacancy bits. For instance,  convertation from char to int, the most improtant thing is keeping the value unchanged. For any positive value of char type, we fill 24 0. For any negtive value of char type, we filee 24 1. For instance , 1111 1100=-4, the int is 0xff ff ff fc(1111 1100)  . If we convert one int to ont float , There is some complex operation to finish.

All the above conversions are kind of standard conversion, there is still another conversion:forced conversion. there is no complement, no add 1. Baed on the changing of  point, the machine just explain the real bits in the memary, and do not change bits. 

2  About the parameters of functions. const parameter

3 For a point a ,a++ is rather different with a=a+1

4 sizeof(long long) is 8. I do not even know this kind of spelling!  but in the function of "printf", the format is %d, so for every parameter, it only read 4 Bytes every time, then we can find the real resluts .Note that it is little-endian storage.

 5 operation system   : kernel mode and user mode: the kernel mode has the highest priority, and does some operation such as resource allocation, computing adn so on. the user mode mainly lies on the cache. Some approaches from the suer mode to the kernel mode: 1)system calling (like applying a new process);2)interruption of peripherals(finishing the reading disks);3) some specific conversion operation(search information following the describer, keep the current information, keep them in regesters) open function belonging to system calling can open device files, fopen belonging to the standard C library can open general files.

6 some algorithms about memary management. Lru least recently used

7 DMA 在实现DMA传输时,是由DMA控制器直接掌管总线,因此,存在着一个总线控制权转移问题。即DMA传输前,CPU要把总线控制权交给DMA控制器,而在结束DMA传输后,DMA控制器应立即把总线控制权再交回给CPU。

8 I am not familar about the concepts of trees,  what a pity.

keep studying ,

Thanks my friend XinXin Zhang, who helps me fighure out most of the above mentioned thing patiently.

Sometimes I feel discussion contributes to keep things in mind and long time. After discussion , we conclude it and check them in the book c++ primer.

原文地址:https://www.cnblogs.com/18fanna/p/3022005.html