騰訊筆試題

2021-04-21 06:03:32 字數 4706 閱讀 8216

一.

單選題(每題4

分,15題,

共60分)

1.考慮函式原型void hello(int a,int b=7,char* pszc="*"),下面的函式呼叫鐘,屬於不合法呼叫的是:

a hello(5)b.hello(5,8)

c.hello(6,"#")

d.hello(0,0,"#") 2.

下面有關過載函式的說法中正確的是: a.

過載函式必須具有不同的返回值型別b.過載函式形參個數必須不同 c.

過載函式必須有不同的形參列表

d.過載函式名可以不同 3.

分析一下程式的執行結果:

#include

class

cbase ;

class

csub : public cbase ;

void

main()

a. constructing csub classb. constructing cbase class

constructing cbase classconstructing csub class

destructing csub classdestructing cbase class

destructing cbase classdestructing 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 ;

virtual

void functiona(){}; };

class

classb ;

}; class

classc : public classa,public classb ;

classc

aobject;

classa* pa=&aobject;

classb* pb=&aobject;

classc* pc=&aobject;

關於pa,pb,pc的取值,下面的描述中正確的是:

a.pa,pb,pc

的取值相同.b.pc=pa+pb

c.pa

和pb不相同

d.pc

不等於pa也不等於pb 6.

參照1.5的**,假設定義了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.delete pab.delete pbc.delete pc 8.

下列程式的執行結果為:

#include

void

main()

a.0.5 b.0c

0.7d.0.6666666-

9.有如下一段**:

#define add(x,y) x+y

intm=3;

m+=m*add(m,m);

則m的值為:

a.15b

.12c

.18d.58

10.如下是乙個帶權的圖,圖中結點a到結點d的關鍵路徑的長度是:

a.13b

.15c

.28d.58

11.下面的模板宣告中,正確的是:

a.template

b.template

c.template

d.template

12.在windows程式設計中下面的說法正確的是: a.

兩個視窗,他們的視窗控制代碼可以是相同的b.兩個視窗,他們的處理函式可以是相同的 c.

兩個視窗,他們的視窗控制代碼和視窗處理函式都不可以相同.

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

a.class

b:public a{}b.class a:public b{}

c.class

bd.class a

14.某公司使用包過濾防火牆控制進出公司區域網的資料,在不考慮使用**伺服器的情況下,下面描述錯誤的是

」該防火牆能夠()」.

a.使公司員工只能訪問internet上與其業務聯絡的公司的ip位址. b.

僅允許http協議通過,不允許其他協議通過,例如tcp/udp. c.

使員工不能直接訪問ftp伺服器端口號為21的ftp位址. d.

僅允許公司中具有某些特定ip位址的計算機可以訪問外部網路

15.數字字元0的ascii值為48,若有以下程式:

main()

程式執行之後的輸出結果是:

a.3,2b.50,2c

.2,2

d.2,50 二

.填空題(共

40分)

本程式從正文檔案

text.in

讀入一篇英文短文

,統計該短文中不同單詞和它的出現次數

,並按詞典編輯順序將單詞及它的出現次數輸出到正文檔案

word.out中.

程式用一棵有序二叉樹儲存這些單詞及其出現的次數

,一邊讀入一邊建立

.然後中序遍歷該二叉樹

,將遍歷經過的二叉樹上的節點的內容輸出

.

程式中的外部函式

int getword(file* pfile,char* pszwordbuffer,int nbufferlen);

從與pfile

所對應的檔案中讀取單詞置入

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

bnode;

int getword(file* pfile,char* paswordbuffer,int nbufferlen);

void binary_tree(bnode** ppnode,char* pszword)

else

}

}

pcurrent=new bnode;

if(pcurrentnode != null)

if(pmemonode==null)

else if(nstrcmpres>0)

else

}

void midorder(file* pfile,bnode* pnode)

void main()

;pfile=fopen(source_file,"r");

if(pfile==null)

while(getword(pfile,szword,max_word_len)==1)

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

;void filluserinfo(userinfo* paruserinfo)

}

int main(int argc,char* argv)

;filluserinfo(aruserinfos);

printf("the first name is:");

printf(aruserinfos[0].szname);

printf("/n");

return 0;}2.

假設你在編寫乙個使用多執行緒技術的程式

,當程式中止執行時

,需要怎樣乙個機制來安全有效的中止所有的執行緒

?請描述其具體流程

.

騰訊筆試題

1 請定義乙個巨集,比較兩個數a b的大小,不能使用大於 小於 if語句 2 如何輸出原始檔的標題和目前執行行的行數 3 兩個數相乘,小數點後位數沒有限制,請寫乙個高精度演算法 4 寫乙個病毒 5 有a b c d 四個人,要在夜裡過一座橋。他們通過這座橋分別需要耗時1 2 5 10分鐘,只有一支手...

騰訊筆試題

const的含義及實現機制,比如 const int i,是怎麼做到i只可讀的?const用來說明所定義的變數是唯讀的。這些在編譯期間完成,編譯器可能使用常數直接替換掉對此變數的引用。初探編譯器static const之實現原理 到商店裡買200的商品返還100優惠券 可以在本商店代替現金 請問實際...

騰訊筆試題

const的含義及實現機制,比如 const int i,是怎麼做到i只可讀的?const用來說明所定義的變數是唯讀的。這些在編譯期間完成,編譯器可能使用常數直接替換掉對此變數的引用。到商店裡買200的商品返還100優惠券 可以在本商店代替現金 請問實際上折扣是多少?由於優惠券可以代替現金,所以可以...