當前位置:學問谷 >

職場範例 >職場百科 >

騰訊技術類校園招聘筆試試題(A8卷)

騰訊技術類校園招聘筆試試題(A8卷)

一. 單選題(每題4分,15題,共60分)

騰訊技術類校園招聘筆試試題(A8卷)

1.考慮函數原型void hello(int a,int b=7,char* pszC=”*”),下面的函數調用鍾,屬於不合法調用的是:

A hello(5) o(5,8) o(6,”#”) o(0,0,”#”)

2.下面有關重載函數的説法中正確的是:

A.重載函數必須具有不同的返回值類型 B.重載函數形參個數必須不同

C.重載函數必須有不同的形參列表 D.重載函數名可以不同

3.分析一下程序的運行結果:

#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.該變量不能在類的'成員函數中引用

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;

關於pA,pB,pC的取值,下面的描述中正確的是:

,pB,pC的取值相同. =pA+pB

和pB不相同 不等於pA也不等於pB

6.參照1.5的代碼,假設定義了ClassA* pA2,下面正確的代碼是:

2=static_cast(pB);

* pVoid=static_cast(pB);

pA2=static_cast(pVoid);

2=pB;

2=static_cast(static_cast(pB));

7.參照1.5的代碼,下面那一個語句是不安全的:

A. pA B. pB C. pC

8.下列程序的運行結果為:

#include

void main()

{

int a=2;

int b=++a;

cout<

A.0.5 B.0 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.如下是一個帶權的圖,圖中結點A到結點D的關鍵路徑的長度是:

A.13 B.15 C.28 D.58

11.下面的模板聲明中,正確的是:

late

late

late

late

12.在Windows編程中下面的説法正確的是:

A.兩個窗口,他們的窗口句柄可以是相同的 B.兩個窗口,他們的處理函數可以是相同的

C.兩個窗口,他們的窗口句柄和窗口處理函數都不可以相同.

13.下面哪種情況下,B不能隱式轉換為A?

s B:public A{} s A:public B{}

s B{operator A();} s A{A(const B&);}

14.某公司使用包過濾防火牆控制進出公司局域網的數據,在不考慮使用代理服務器的情況下,下面描述錯誤的是”該防火牆能夠( )”.

A.使公司員工只能訪問Internet上與其業務聯繫的公司的IP地址.

B.僅允許HTTP協議通過,不允許其他協議通過,例如TCP/UDP.

C.使員工不能直接訪問FTP服務器端口號為21的FTP地址.

D.僅允許公司中具有某些特定IP地址的計算機可以訪問外部網絡

15.數字字符0的ASCII值為48,若有以下程序:

main()

{

char a=’1’,b=’2’;

printf(“%c,”,b++);

printf(“%d”,b-a);

}

程序運行之後的輸出結果是:

A.3,2 B.50,2 C.2,2 D.2,50

二. 填空題(共40分)

本程序從正文文件讀入一篇英文短文,統計該短文中不同單詞和它的出現次數,並按詞典編輯順序將單詞及它的出現次數輸出到正文文件中.

程序用一棵有序二叉樹存儲這些單詞及其出現的次數,一邊讀入一邊建立.然後中序遍歷該二叉樹,將遍歷經過的二叉樹上的節點的內容輸出.

程序中的外部函數

int getword(FILE* pFile,char* pszWordBuffer,int nBufferLen);

從與pFile所對應的文件中讀取單詞置入pszWordBuffer,並返回1;若單詞遇文件尾,已無單詞可讀時,則返回0.

#include

#include

#include

#include

#define SOURCE_FILE “”

#define OUTPUT_FILE “”

#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”,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”,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. 從程序健壯性進行分析,下面的FillUserInfo函數和Main函數分別存在什麼問題?

#include

#include

#define MAX_NAME_LEN 20

struct USERINFO

{

int nAge;

char szName[MAX_NAME_LEN];

};

void FillUserInfo(USERINFO* parUserInfo)

{

stu::cout<<”請輸入用户的個數:”;< p="">

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]me,strName.c_str());

}

}

int main(int argc,char* argv[])

{

USERINFO arUserInfos[100]={0};

FillUserInfo(arUserInfos);

printf(”The first name is:”);

printf(arUserInfos[0]me);

printf(””);

return 0;

}

2. 假設你在編寫一個使用多線程技術的程序,當程序中止運行時,需要怎樣一個機制來安全有效的中止所有的線程?請描述其具體流程.

  • 文章版權屬於文章作者所有,轉載請註明 https://xuewengu.com/flzc/baike/2veom3.html