2015年騰訊筆試題,歡迎閱讀借鑒!
騰訊筆試題
一. 單選題(每題4分,15題,共60分)
1.考慮函數(shù)原型void hello(int a,int b=7,char* pszC= * ),下面的函數(shù)調(diào)用鐘,屬于
不合法調(diào)用的是:
A hello(5) B.hello(5,8) C.hello(6, # ) D.hello(0,0, # )
2.下面有關(guān)重載函數(shù)的說法中正確的是:
A.重載函數(shù)必須具有不同的返回值類型 B.重載函數(shù)形參個數(shù)必須不同
C.重載函數(shù)必須有不同的形參列表 D.重載函數(shù)名可以不同
3.分析一下程序的運行結(jié)果:
#include
class CBase
public:
CBase{cout《《”constructing CBase class”《
~CBase{cout《《”destructing CBase class”《
class CSub : public CBase
public:
CSub{cout《《”constructing CSub class”《
~CSub{cout《《”destructing CSub class”《
void main
CSub obj;
A. constructing CSub class B. constructing CBase class
constructing CBase class constructing CSub class
destructing CSub class destructing CBase class
destructing CBase class destructing CSub class
C. constructing CBase class
constructing CSub class
destructing CSub class
destructing CBase class
D. constructing CSub class
constructing CBase class
destructing CBase class
destructing CSub class
4.在一個cpp文件里面,定義了一個static類型的全局變量,下面一個正確的描述是:
A.只能在該cpp所在的編譯模塊中使用該變量
B.該變量的值是不可改變的
C.該變量不能在類的成員函數(shù)中引用
D.這種變量只能是基本類型(如int,char)不能是C++類型
5.觀察下面一段代碼:
class ClassA
public:
virtual ~ ClassA{};
virtual void FunctionA{};
class ClassB
public:
virtual void FunctionB{};
class ClassC : public ClassA,public ClassB
public:
ClassC aObject;
ClassA* pA=&aObject;
ClassB* pB=&aObject;
ClassC* pC=&aObject;
關(guān)于pA,pB,pC的取值,下面的描述中正確的是:
A.pA,pB,pC的取值相同. B.pC=pA+pB
C.pA和pB不相同 D.pC不等于pA也不等于pB
6.參照1.5的代碼,假設(shè)定義了ClassA* pA2,下面正確的代碼是:
A.pA2=static_cast(pB);
B.void* pVoid=static_cast(pB);
pA2=static_cast(pVoid);
C.pA2=pB;
D.pA2=static_cast(static_cast(pB));
7.參照1.5的代碼,下面那一個語句是不安全的:
A. pA B. pB C. pC
8.下列程序的運行結(jié)果為:
#include
void main
int a=2;
int b=++a;
cout《
A.0.5 B.C0.7 D.0.6666666-
9.有如下一段代碼:
#define ADD(x,y) x+y
int m=3;
m+=m*ADD(m,m);
則m的值為:
A.15 B.12 C.18 D.58
10.如下是一個帶權(quán)的圖,圖中結(jié)點A到結(jié)點D的關(guān)鍵路徑的長度是:
A.13 B.15 C.28 D.58
11.下面的模板聲明中,正確的是:
A.template
B.template
C.template
D.template
12.在Windows編程中下面的說法正確的是:
A.兩個窗口,他們的窗口句柄可以是相同的 B.兩個窗口,他們的處理函數(shù)可以是相同
C.兩個窗口,他們的窗口句柄和窗口處理函數(shù)都不可以相同.
13.下面哪種情況下,B不能隱式轉(zhuǎn)換為A?
A.class B:public A{} B.class A:public B{}
C.class B{operator A;} D.class A{A(const B&);}
14.某公司使用包過濾防火墻控制進(jìn)出公司局域網(wǎng)的數(shù)據(jù),在不考慮使用代理服務(wù)器的情
況下,下面描述錯誤的是”該防火墻能夠( )”.
A.使公司員工只能訪問Internet上與其業(yè)務(wù)聯(lián)系的公司的IP地址.
B.僅允許HTTP協(xié)議通過,不允許其他協(xié)議通過,例如TCP/UDP.
C.使員工不能直接訪問FTP服務(wù)器端口號為21的FTP地址.
D.僅允許公司中具有某些特定IP地址的計算機(jī)可以訪問外部網(wǎng)絡(luò)
15.數(shù)字字符0的ASCII值為48,若有以下程序:
main
char a=’1’,b=’2’;
printf(“%c,”,b++);
printf(“%d\n”,b-a);
程序運行之后的輸出結(jié)果是:
A.3,2 B.50,2 C.2,2 D.2,50
二. 填空題(共40分)
本程序從正文文件text.in讀入一篇英文短文,統(tǒng)計該短文中不同單詞和它的出現(xiàn)次數(shù),并
按詞典編輯順序?qū)卧~及它的出現(xiàn)次數(shù)輸出到正文文件word.out中.
程序用一棵有序二叉樹存儲這些單詞及其出現(xiàn)的次數(shù),一邊讀入一邊建立.然后中序遍歷
該二叉樹,將遍歷經(jīng)過的二叉樹上的節(jié)點的內(nèi)容輸出.
程序中的外部函數(shù)
int getword(FILE* pFile,char* pszWordBuffer,int nBufferLen);
從與pFile所對應(yīng)的文件中讀取單詞置入pszWordBuffer,并返回1;若單詞遇文件尾,已無
單詞可讀時,則返回0.
#include
#include
#include
#include
#define SOURCE_FILE text.in
#define OUTPUT_FILE word.out
#define MAX_WORD_LEN 128
typedef struct treenode
char szWord[MAX_WORD_LEN];
int nCount;
struct treenode* pLeft;
struct treenode* pRight;
}BNODE;
int getword(FILE* pFile,char* pasWordBuffer,int nBufferLen);
void binary_tree(BNODE** ppNode,char* pszWord)
if(ppNode != NULL && pszWord != NULL)
BNODE* pCurrentNode = NULL;
BNODE* pMemoNode = NULL;
int nStrCmpRes=0;
____(1)_____;pCurrentNode=*ppNode
while(pCurrentNode)
/*尋找插入位置*/
nStrCmpRes = strcmp(pszWord, ___(2)___ );pCurrentNode-
》nCount
if(!nStrCmpRes)
___(3)___; pCurrentNode-》nCount++
return;
else
___(4)___; pMemoNode=pCurrentNode
pCurrentNode = nStrCmpRes》0? pCurrentNode-
》pRight : pCurrentNode-》pLeft;
pCurrent=new BNODE;
if(pCurrentNode != NULL)
memset(pCurrentNode,0,sizeof(BNODE));
strncpy(pCurrentNode-》szWord,pszWord,MAX_WORD_LEN-1);
pCurrentNode-》nCount=1;
if(pMemoNode==NULL)
___(5)___; *ppNode= pCurrentNode
else if(nStrCmpRes》0)
pMemoNode-》pRight=pCurrentNode;
else
pMemoNode-》pLeft=pCurrentNode;
void midorder(FILE* pFile,BNODE* pNode)
if(___(6)___) return;!pNode||!pFile
midorder(pFile,pNode-》pLeft);
fprintf(pFile, %s %d\n ,pNode-》szWord,pNode-》nCount);
midorder(pFile,pNode-》pRight);
void main
FILE* pFile=NULL;
BNODE* pRootNode=NULL;
char szWord[MAX_WORD_LEN]={0};
pFile=fopen(SOURCE_FILE, r );
if(pFile==NULL)
printf( Can't open file %s\n ,SOURCE_FILE);
return;
while(getword(pFile,szWord,MAX_WORD_LEN)==1)
binary_tree(___(7)___); pRootNode,szWord
fclose(pFile);
pFile=fopen(OUTPUT_FILE, w );
midorder(pFile,pRootNode);
fclose(pFile);
三. 附加題(每題30分,2題,共60分)
1. 從程序健壯性進(jìn)行分析,下面的FillUserInfo函數(shù)和Main函數(shù)分別存在什么問
#include
#include
#define MAX_NAME_LEN 20
struct USERINFO
int nAge;
char szName[MAX_NAME_LEN];
void FillUserInfo(USERINFO* parUserInfo)
stu::cout《《 請輸入用戶的個數(shù): ;
int nCount=0;
std::cin》》nCount;
for(int i=0;i
std::cout《《 請輸入年齡: ;
std::cin》》parUserInfo[i]-》nAge;
std::string strName;
std::cout《《 請輸入姓名: ;
std::cin》》strName;
strcpy(parUserInfo[i].szName,strName.c_str);
int main(int argc,char* argv)
USERINFO arUserInfos[100]={0};
FillUserInfo(arUserInfos);
printf( The first name is: );
printf(arUserInfos[0].szName);
printf( \n );
return 0;
2. 假設(shè)你在編寫一個使用多線程技術(shù)的程序,當(dāng)程序中止運行時,需要怎樣一個機(jī)
制來安全有效的中止所有的線程?請描述其具體流程.
騰訊筆試題
考試時間60分鐘,整張試卷分四大部分。
第一部分?jǐn)?shù)據(jù)分析,整個部分分為三個大題,每個大題5個小題,不難,圖表計算。
第二部分邏輯推理,普通的行測題,一共有10道選擇。難易程度跟公務(wù)員的差不多。
第三部分閱讀理解,15道選擇。也是行測類型的,讀一段話,做選擇。
前三個部分都是單選,一共40題。
第四部分論述題,最后論述2道大題。(這部分不算分?jǐn)?shù),對面試有好處)
論述題:
廣州騰訊產(chǎn)品實習(xí)筆試
第一題是如果微信添加一個功能刪除一個功能,你會怎么做?(可見騰訊論述題很注重騰訊產(chǎn)品的考察)
第二題是現(xiàn)在電子商務(wù)創(chuàng)業(yè)很流行,如果有以下電商創(chuàng)業(yè),你會選哪一種:服裝,虛擬產(chǎn)品,生活服務(wù)類。
第三道題,如果你是一個乳制品的公關(guān)經(jīng)理,315曝光你們產(chǎn)品有問題,設(shè)計一個24小時公關(guān)方案,以挽回公司損失。(這個題目我在之前筆試看到過,是寶潔SKII事件,寫新聞發(fā)言稿,所以大家可以注意一下公關(guān)知識)
第四道題,騰訊給你5000元公益資金幫扶特殊群體,設(shè)計一個校園公益項目方案。
北京站產(chǎn)品筆試
附加題一:是用互聯(lián)網(wǎng)思維改造傳統(tǒng)行業(yè),寫一個策劃方案什么的,舉了嘀嘀打車的例子。
附加題二是:題目背景是國務(wù)院批復(fù)了一個文件《前海深港現(xiàn)代服務(wù)業(yè)合作區(qū)總體發(fā)展XXX》,然后問你采取何種措施吸引優(yōu)秀人才的加入,以便支撐入駐企業(yè)的發(fā)展