2015.03.29 腾讯实习笔试(回忆版)

来源:互联网 发布:丽水办公助手软件 编辑:程序博客网 时间:2024/05/16 15:27
1、#define max(a,b) (a)>(b)?(a):(b)
     int x=12,y=10;
     printf("%d\n", max(++x,y));  //14

2、//JavaScript  
      var a=0;
      function one() {
            for(var i=0;i<10;i++) {
                   setTimeout(function() {         
                           a += i;              
                   },0);
            }
      }      //setTimeout延时0毫秒保证在作用域最后执行,所以i在最后一直等于10,
              //a = a+10+10+...+10=100
      function two() {
             alert(a);
      }

      one();
      setTimeout(two,0);  //alert 100
      setTimeout("two()",0);  //alert 100
      setTimeout(two(),0);  //alert 0


3、#include <iostream>
      using namespace std;
      class Base
      {
       public:
               virtual void init() {...}
       protected:
               int a;
               char b;    
      };

      class Derived : public Base
      {
       public:
               virtual void init() {...}
       protected:
               char a;
               int b;   
      };

      int main() 
      {
             cout << sizeof(Derived) << endl;      //20
             return 0;
      }

4、//aa.c
      #include <stdio.h>
      void main()
      {
             #ifdef aa
                    int a = 0;
             #else
                    int a = 1;
             #endif

             #ifdef bb
                    int b = 0;
             #else
                    int b = 1;
             #endif

             printf("%d%d",a,b);             
      }
      执行gcc -Daa 结果       //should be 01

5、以往2月份工人发现设备故障概率为75% ,问2月份其中一个星期发现设备故障的概率是多少?

6、100个学生做题,做对第一题有81人,做对第二题有91人,做对第三题有85人,做对第四题有79人,做对第五题有74人。现在规定答对三道或三道以上的为及格,问至少多少人及格?

7、vector和list优缺点对比

8、Redis :是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。

9、autoRelease

10、int (*func[5])(int *)  func是个什么东西?

11、中国围棋棋盘由19*19条线垂直相交而成,有361个交点,问有多少个正方形? 

12、JVM释放内存??

13、数据库范式:第二范式(不能部分依赖)、第三范式(不能存在传递依赖)

14、string类方法find返回值 string::npos 即 -1



问答:
1、有1亿个的QQ号,用set和vector存储,写代码剔除单数的QQ号。

2、猴子摘香蕉,一次只能摘1支或2支,问摘50支香蕉有多少种摘法?

3、折半查找(二分查找)填空。

4、malloc和free用来申请和释放内存,但free真的将内存还给了OS吗?如果不是,请分别举例说明。

PS:回忆版,很多都只是一个梗概!勿喷!尴尬
0 0
原创粉丝点击