Chinaunix首页 | 论坛 | 博客
  • 博客访问: 180165
  • 博文数量: 33
  • 博客积分: 2047
  • 博客等级: 大尉
  • 技术积分: 333
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-21 19:35
文章分类

全部博文(33)

文章存档

2011年(1)

2010年(21)

2009年(11)

分类:

2010-10-17 22:22:39

腾讯笔试题,同学回忆的如下:
1、int a[10];  sizeof(a)=?

2、
struct node{
    char *name;
    char a;
}*p;
下列哪些是正确的?
*p.name = 0;
(*p).name = 0;
p->name = 0;
(*p).name = 0;

3、哪些是正确的?
socket通信中,recv  &  send
A send发送一次数据成功后,接收方一定能够收到发送的数据?
B、send两次发送数据,接收方能一次接收完两份数据?
C、send两次发送数据,接收方可能两次接收完数据?
D、recv接收数据时,若没有数据是否一直等待直到有数据可接收?

4、排它锁的作用?

5、数据库索引知识点,Select语句什么时候能够用到索引字段的索引功能?

6、mask  255.255.248.0 的网络中子网中最大主机数量?


7 、2010^2010 % 17  ==??


8、class A{
    A(){cout<<"A()"};
    }

class B:A
{}
class C:B{
}

构造函数调用顺序的问题。。

9 关于private,protected、继承的相关知识点,能否访问?

10、指针与引用的差别?是否需要初始化? 成员变量是否可以为引用(可以)

11、5,7,10 指针与引用的题目
void m(int &c)
{
    int *p = &c;
    *p = 7;
}

void n(int c)
{
    int *p = &c;
    *p = 4;
}
int main(int argc, char **argv)
{
    int i = 4, *d, **e;
    d = &i;
    e = &d;
    **e = 5;
    cout << i << ' ';
    m(i);
    n(*d);
    cout << i << ' ';
    i = 10;
    cout << **e << endl;

    return 0;
}
程序输出结果?


12 递归调用

int f(int a)
{
    if(a==0 || a==1)
        return 1;
    else if(a%2 == 0)
        return f(a/2)+2;
    else
        return f(a-1)+3;
}

 f(12)等于多少?
 
13  进程与线程的问题
 
14、进程就绪与阻塞、等待的问题
 

程序填空题:
hash表操作。
先从一个双链表节点中取得一个节点,然后添加到hash表中
双链表和hashobj结构如下:
struct _hash_key
{
    long _key;
    struct _hash_obj *prev;
    struct _hash_obj *next;
};

struct _hash_obj
{
    void *data;    // 数据包指针
    struct _hash_obj *next_obj;
    struct _hash_key hash_key;
};

// 空闲链表,是存放空闲的hash_obj指针的链表
struct IdleList
{
    struct _hash_obj *head;
    struct _hash_obj *tail;
};

// 假设一下两个变量正确初始化了
struct IdleList *m_IdleList;
struct hash_obj **m_ppHashObj;

// 填空
void insert_hash_obj(long key, void *data)
{
}


附加题:
查找单词{internet、video、。。。}在一个文件中出现的次数,要求有时间分析、
空间分析?数据结构和算法说明。

15、给定一个乱序序列,求冒泡排序一趟后的结果

16、二叉树先序和后序遍历结果一样,那么这棵树是什么样的?
   A 根节点没有左子树?
   B 只有根节点?
   C 根节点没有右子树?
   D 普通的二叉树?

其中一些题的验证程序:
// QQ 2011 Recruitment
#include
#include
using namespace std;

void test01()
{
    struct node
    {
        char *name;
    } *p;

    struct node a = {"Hello"};

    p = &a;
    printf("%s\n", (*p).name);        // .(成员操作符)优先于*(解引用操作符),*p.name编译错误
    cout << (*p).name << endl;
}

int test02(int a)
{
    if(a == 0 || a == 1)
        return 1;
    else if(a%2 == 0)
        return test02(a/2) + 2;
    else
        return test02(a-1) + 3;
}

class A
{
public:
    A()
    {
        cout << "A()";
    }
   
    ~A()
    {
        cout <<"~A()";
    }
};

class B: public A
{
public:
    B()
    {
        cout << "B()";
    }

    ~B()
    {
        cout <<"~B()";
    }
};

class C: public B
{
public:
    C()
    {
        cout << "C()";
    }

    ~C()
    {
        cout <<"~C()";
    }
};

void m(int &c)
{
    int *p = &c;
    *p = 7;
}

void n(int c)
{
    int *p = &c;
    *p = 4;
}

int main(int argc, char **argv)
{
    test01();

    int i = 4, *d, **e;
    d = &i;
    e = &d;
    **e = 5;
    cout << i << ' ';
    m(i);
    n(*d);
    cout << i << ' ';
    i = 10;
    cout << **e << endl;

    cout << test02(12) << endl;

    B b;
    A *pA = new C();
    delete pA;

    return 0;
}
 
阅读(928) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~