http://blog.csdn.net/silangquan/article/details/18051675


网上弄到的一份题,不是很完整,边猜边做。


1.写出运行结果

char array[] = “abcde”; char* s = array;

cout<<sizeof(array)<<strlen(array)<<sizeof(s)<<strlen(s);

6585

2.什么是用户级线程和内核级线程?区别。

内核级线程:
(1)线程的创建、撤销和切换等,都需要内核直接实现,即内核了解每一个作为可调度实体的线程。
(2)这些线程可以在全系统内进行资源的竞争。
(3)内核空间内为每一个内核支持线程设置了一个线程控制块(TCB),内核根据该控制块,感知线程的存在,并进行控制。
在一定程度上类似于进程,只是创建、调度的开销要比进程小。有的统计是1:10
用户级线程:
(1)用户级线程仅存在于用户空间。——>对比内核(3)
(2)内核并不能看到用户线程。——>重要的区别

(3)内核资源的分配仍然是按照进程进行分配的;各个用户线程只能在进程内进行资源竞争。

3.从C++文件到生成exe 文件经过哪三个步骤?

预编译,编译优化,汇编,链接

4.有个二维数组 A(6*8),每个元素占 6 字节,起始地址为 1000,请问最后一个元素 A[5][7]的起始地址为??? 数组A占内存大小为??? 假设以行优先,则A[1][4]起始地址为???

1)1000 + 6*6*8 - 8 = 11282; 2)6*6*8=288; 3)A[1][4]位置为5行2列,1000+6*(8*1+4) = 1272.

如果给出结构体,考虑到字节对齐的话就要另外考虑了。

5.用C语言把双向链表中的两个结点交换位置,考虑各种边界问题。

考虑三种情况:第一个结点在头,第一个结点在中间,第一个结点在尾巴。

[cpp] view plaincopy
  1. struct Node{
  2. Node* prev;
  3. Node* next;
  4. void* data;
  5. };
  6. struct LinkedList{
  7. Node*    head;
  8. Node*    tail;
  9. Node*    cur;
  10. int      size;
  11. };
  12. bool exchange(LinkedList* list,Node *node1,Node *node2)
  13. {
  14. if(node1== NULL || node2==NULL)
  15. return false;
  16. Node *p,*q;
  17. //node1 on the front
  18. if(list->head->next == node1)
  19. {
  20. //node2 on the last
  21. if(list->tail->next == node2)
  22. {
  23. p = node2->prev;
  24. //Cope with node2
  25. list->head->next = node2;
  26. node2->prev = list->head;
  27. node2->next = node1->next;
  28. node2->next->pre = node2;
  29. //Cope with node1
  30. list->tail->prev = node1;
  31. node1->next = list->tail;
  32. node1->prev = p;
  33. p->next = node1;
  34. return true;
  35. }
  36. //node2 not on the last
  37. else
  38. {
  39. p = node2->prev;
  40. q = node2->next;
  41. //Cope with node2
  42. list->head->next = node2;
  43. node2->prev = list->head;
  44. node2->next = node1->next;
  45. node2->next->prev = node2;
  46. //Cope with node1
  47. p->next = node1;
  48. node1->prev = p;
  49. node1->next = q;
  50. q->prev = node1;
  51. return true;
  52. }
  53. }
  54. //node1 on the last
  55. else if(list->tail->next == node1)
  56. {
  57. //node2 on the front
  58. if(list->head->next == node2)
  59. {
  60. p = node1->prev;
  61. //Cope with node1
  62. list->head->next = node1;
  63. node1->prev = list->head;
  64. node1->next = node2->next;
  65. node1->next->prev = node1;
  66. //Cope with node2
  67. list->tail->prev = node2;
  68. node2->next = list->tail;
  69. node2->prev = p;
  70. p->next = node2;
  71. return true;
  72. }
  73. //node2 not on the front
  74. else
  75. {
  76. p = node2->prev;
  77. q = node2->next;
  78. //Cope with node2
  79. list->tail->next = node2;
  80. node2->prev = list->tail;
  81. node2->next = node1->next;
  82. node2->next->prev = node2;
  83. //Cope with node1
  84. p->next = node1;
  85. node1->prev = p;
  86. node1->next = q;
  87. q->prev = node1;
  88. return true;
  89. }
  90. }
  91. //node1 on the middle
  92. else
  93. {
  94. //node2 on the front
  95. if(list->head->next == node2)
  96. {
  97. p = node1->prev;
  98. q = node1->next;
  99. node1->prev = list->head;
  100. list->head->next = node1;
  101. node1->next = node2->next;
  102. node2->next->prev = node1;
  103. node2->prev = p;
  104. p->next = node2;
  105. node2->next = q;
  106. q->prev = node2;
  107. }
  108. //node2 on the last
  109. else if(list->tail->next == node2)
  110. {
  111. p = node1->prev;
  112. q = node1->next;
  113. node1->prev = node2->prev;
  114. node2->prev->next = node1;
  115. node1->next = list->tail;
  116. list->tail->prev = node1;
  117. node2->prev = p;
  118. p->next = node2;
  119. node2->next = q;
  120. q->prev = node2;
  121. }
  122. //both in the middle
  123. else
  124. {
  125. p = node2->prev;
  126. q = node2->next;
  127. //Cope with node2
  128. node2->prev = node1->prev;
  129. node1->prev->next = node2;
  130. node2->next = node1->next;
  131. node1->next->prev = node2;
  132. //Cope with node1
  133. p->next = node1;
  134. node1->prev = p;
  135. node1->next = q;
  136. q->prev = node1;
  137. return true;
  138. }
  139. }
  140. }

6.*.dll,*.lib,*.exe 文件分别是什么,有什么区别?

lib是静态的库文件,dll是动态的库文件。 
所谓静态就是link的时候把里面需要的东西抽取出来安排到你的exe文件中,以后运行exe的时候不再需要lib。 
所谓动态就是exe运行的时候依赖于dll里面提供的功能,没有这个dll,exe无法运 行。

lib, dll, exe都算是最终的目标文件,是最终产物。而c/c++属于源代码。源代码和最终 目标文件中过渡的就是中间代码obj,实际上之所以需要中间代码,是你不可能一次得到目 标文件。比如说一个exe需要很多的cpp文件生成。而编译器一次只能编译一个cpp文件。这 样编译器编译好一个cpp以后会将其编译成obj,当所有必须要的cpp都编译成obj以后,再统 一link成所需要的exe,应该说缺少任意一个obj都会导致exe的链接失败.

7.附加题(20):使用八叉树算法把24位真彩色转化成 256色。24位真彩色包括 R,G,B颜色,每种颜色8 位。

在计算机中像素的计算单位一般是二进制的,256色,即2的8次方,因此我们也把256色图形叫做8位图;16位图,它可以表达2的16次方即65536种颜色;还有24位彩色图,可以表达16,777,216种颜色。

算法参考:http://blog.csdn.net/zuzubo/article/details/1597985

8.有 11 盆花,围成一圈,要求每次组合时,每盆花相邻的两盆花与上次不同,请问有多少排列方法? 

待解答。

9.2 只宠物合成,1只有 5技能,1 只有4 技能,每个技能有 a%概率遗传,请问刚好有7 个技能遗传成功的概率是?

只有

第一只5个技能 + 第二只2个技能:(a%)^7*C(4,2)

第一只4个技能 + 第二只3个技能:(a%)^7*C(5,4)*C(4,3)

第一只3个技能 + 第二只4个技能:(a%)^7*C(5,3)

加起来就可以了。

10.输出结果为?

[cpp] view plaincopy
  1. #include <iostream>
  2. using namespace std;
  3. class A
  4. {
  5. public:
  6. A(){cout<<"1";}
  7. A(A &a){cout <<"2";}
  8. virtual ~A() {cout<<"3";}
  9. };
  10. class B:public A
  11. {
  12. public:
  13. B(){cout<<"4";}
  14. B(B &b){cout<<"5";}
  15. ~B(){cout<<"6";}
  16. };
  17. int main()
  18. {
  19. A* pa = new B();
  20. delete pa;
  21. return 0;
  22. }

1463

子类构造之前首先调用基类的构造函数,然后是子类的构造函数,析构的时候相反,注意基类的析构函数声明为virtual才可以.

网易2011笔试题详解相关推荐

  1. 剑指XX游戏(二) - 网易2011笔试题详解

    网上弄到的一份题,不是很完整,边猜边做. 1.写出运行结果 char array[] = "abcde"; char* s = array; cout<<sizeof( ...

  2. 蘑菇街2015校招 Java研发笔试题 详解,2015java

    蘑菇街2015校招 Java研发笔试题 详解,2015java 1. 对进程和线程描述正确的是( ) A.  父进程里的所有线程共享相同的地址空间,父进程的所有子进程共享相同的地址空间. B.  改变 ...

  3. c语言进阶(3)——指针进阶笔试题详解

    1.指针和数组笔试题解析 关键:数组名在两种情况下是指整个数组: (1)sizeof(数组名)(2)&数组名 其它的情况下,都是代表数组的首元素地址. 例题 1 :一维数组 int main( ...

  4. mysql 笔试题_MySQL笔试题详解(一)(中等难度)

    有一位学生在找数据分析工作的时候,遇到一个笔试题,内容如下: 现有注册用户表table_user,有两个字段:user_id(用户id).reg_tm(注册时间).有订单表table_order,有三 ...

  5. 2018 美团校招笔试题详解

    栈必考题目 栈和队列必考题目 不选安全性,可以猜出是ABD 操作系统死锁的题目经常考 这题也是一道必考题 二叉树必考题 第一张抽出红的,第二张抽出黑的,概率是P=1/2* 26/51 第一张抽出黑的, ...

  6. 2020年小红书校招数据分析笔试题详解

    1.如果在小红书商城中某一商户给一产品定价,如果按照全网最低价500元定价,那么客人就一定会选择在此购买:价格每增加1元,客人的流失的可能性就会增加1%.那么该商户给客人报出最优价格为() A.520 ...

  7. python 数据类笔试题_一道 Python 类的笔试题详解

    r = {} class C(object): def __init__(self, a, b): self.a = a self.b = b if b == 'a': orig = super(C, ...

  8. 微软2013年笔试题详解及深入

    Microsoft 下面哪些调用转换支持可变长度参数: A. cdecl  B. stdcall  C. pascal  D. fastcall 几种函数调用方式: __cdecl 是C Declar ...

  9. 大疆FPGA/芯片开发工程师(A卷、B卷)笔试题详解

    大疆芯片开发岗A卷 文章目录 一.单选题 / 多选题 **说明:答案仅供参考,个别可能存在错误.** 一.单选题 / 多选题 1.(单选)关于流水线设计的理解,错误的是C   A.流水线可以提高系统并 ...

最新文章

  1. 机械转嵌入式还是java,机械硕士转嵌入式后悔吗?
  2. android底部滑出view,Android CoordinatorLayout与NestedScrollView基于Behavior几行代码实现底部View滑入滑出...
  3. jquery获取主机地址和端口
  4. RIP和OSPF双点双向重发布_综合实验
  5. iScroll 5 API 中文版
  6. LintCode 1689. k求和III(递归)
  7. mysql 及时点还原_mysqlbinglog基于即时点还原
  8. vim 配置_「go」 配置vim用于go 开发
  9. android 练习之路 (一)
  10. Android 应用开发---API Level对应Android版本一览表
  11. 微信服务通知消息找回_如何通过微信第三方平台群发服务号消息通知?
  12. python语言unity3d_Unity3D 中的 IronPython
  13. 【SSH框架】之Spring系列(一)
  14. 全网首发:warning: #warning “Using deprecated NumPy API, disable it by “ “#defining NPY_NO_DEPRECATED_API
  15. c语言文件读写r 的作用,C语言简单读写文件
  16. 手机连接hp打印机打印
  17. SolidWorks-旋转凸台的使用
  18. 普通话测试第四题评分标准_普通话等级考试内容及评分标准
  19. python爬虫从入门到放弃,含案例分析,超详细讲解(一)
  20. Linux桌面环境(桌面系统)大比拼[附带优缺点]

热门文章

  1. 英语语法回顾7——状语从句特殊用法
  2. 详谈Scrum和看板的区别
  3. 关于双击此电脑、回收站、控制面板等提示找不到应用程序解决方案
  4. 风力发电系统的一些常见名词
  5. 移动硬盘文件夹不见了怎么办?
  6. 均值归一化_深度神经网络中的归一化技术
  7. jzoj 4246【五校联考6day2】san
  8. VMware虚拟机ubuntu指定使用主机的wifi无线网卡
  9. JB的Shell之旅-30分钟带你入门
  10. python写spark的效率问题_“大数据架构”Spark 3.0发布,重大变化,性能提升18倍...