腾讯笔试题

发布 2024-04-17 03:20:11 阅读 2170

1. 写出判断abcd四个表达式的是否正确, 若正确, 写出经过表达式中 a的值(3分)

int a = 4;

a)a +=a++)b) a +=a) ;c) (a++)a;(d) (a) +a++)

a = 答:c错误,左侧不是一个有效变量,不能赋值,可改为(++a) +a;

改后答案依次为9,10,10,11

2.某32位系统下, c++程序,请计算sizeof 的值(5分).

char str

char *p = str ;

int n = 10;

请计算。sizeof (str ) 1)

sizeof ( p ) 2)

sizeof ( n ) 3)

void foo ( char str[100])++p;

return 0; }

in this case we h**e to bear the knowledge of value type "int", the size of array, even the existence of an array. would you re-write it using template to eliminate all these dependencies?

template

const t *find1(const t* array, int n, t x)

const t* p = array;

for(int i = 0; i < n; i++)++p;

return 0; }

no2give an example of implementing a stack in the template way(only template class declaration without detail definition and realization)

template

class stack

public:

stack(int = 10) ;

~stack()

int push(const t&);

int pop(t&)

int isempty()const

int isfull() const

private:

int size ; number of elements on stack.

int top ;

t* stackptr ;

no3implement the ******st singleton pattern(initialize if necessary).

class singleton

return _instance;

no4and diamond like playing game of coins, one day they designed a new set of rules:

1)totally 10 coins

2)one can take away 1,2or 4 coins at one time by turns

3)who takes the last loses.

given these rules whether the winning status is pre-determined or not

1:从后面开始考虑,最后肯定要留1个才能保证自己赢。

2:所以要设法让对方留下2,3,5个。

3:也就是要自己取后留下1,4,6,7,8,9

4:如果自己取后留下6,对方取2个,与(3)矛盾,所以排除6

5:如果自己取后留下8,对方取4个,与(3)一样情况,所以也排除8

6:同样,9也不行,如果我抽后剩下9,对方抽2个,就反过来成对方抽剩成7个了,也与3)矛盾,所以也排除。

7:所以很显然,我只能抽剩1,4,7

8:因为只能抽后剩1,4,7才能赢,我先抽得话不可能达到这几个数,很显然,只能让对。

方先抽,也即是先抽的人输。

腾讯笔试题

腾讯非技术类笔试题目。一 不定项选择。1976年发生的事。以下哪个不是 政治局常委。什么 文件格式字节大 二 填空。亚运会在那里举行?世界五大通讯社。新闻基本要素。ceo是谁,这个我临时忘了,出来才想起来。一个html语言的意思。三 找出标题的毛病并改正。四 十条国内新闻 十条国际新闻 十条社会新闻...

腾讯笔试题

基本都是基础题目,看来腾讯不准备放弃那些有思想但是还没有开始苦练基本功的人,只涉及到语言问题和简单的数据结构,其他的操作系统,编译原理,离散数学,软件工程,计算机原理,体系结构等等无一涉及,题目很多,有1个选择题想不来起来是什么了,题号不与原试题相符。希望师弟师妹可以 答案,从中学到笔试的经验。1 ...

腾讯笔试题

腾讯的流程是一笔和四面。前三次面试都是技术面,hr面基本不刷人。笔试成绩决定面试顺序。技术面可能要写 做智力题目。主要是c c 数据结构 操作系统等方面的基础知识。好像有sizeof 树等选择题。填空题是补充完整程序。附加题有写算法的 编程的 数据库sql语句查询的。还有一张开放性问题。1 请定义一...