• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            life02

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              197 隨筆 :: 3 文章 :: 37 評(píng)論 :: 0 Trackbacks
            一.  單選題(每題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ù)形參個(gè)數(shù)必須不同

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

              3.分析一下程序的運(yùn)行結(jié)果:

              #include<iostream.h>

              class CBase

              {

              public:

              CBase(){cout<<”constructing CBase class”<<endl;}

              ~CBase(){cout<<”destructing CBase class”<<endl;}

              };

              class CSub : public CBase

              {

              public:

              CSub(){cout<<”constructing CSub class”<<endl;}

              ~CSub(){cout<<”destructing CSub class”<<endl;}

              };

              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.在一個(gè)cpp文件里面,定義了一個(gè)static類型的全局變量,下面一個(gè)正確的描述是:

              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<ClassA*>(pB);

              B.void* pVoid=static_cast<void*>(pB);

              pA2=static_cast<ClassA*>(pVoid);

              C.pA2=pB;

              D.pA2=static_cast<ClassA*>(static_cast<ClassC*>(pB));

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

              A.delete pA   B.delete pB   C.delete pC

              8.下列程序的運(yùn)行結(jié)果為:

              #include<iostream.h>

              void main()

              {

              int a=2;

              int b=++a;

              cout<<a/6<<endl;

              }

              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.如下是一個(gè)帶權(quán)的圖,圖中結(jié)點(diǎn)A到結(jié)點(diǎn)D的關(guān)鍵路徑的長度是:

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

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

              A.template<typename T1,T2>

              B.template<class T1,T2>

              C.template<class T1,class T2>

              D.template<typename T1;typename T2>

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

              A.兩個(gè)窗口,他們的窗口句柄可以是相同的     B.兩個(gè)窗口,他們的處理函數(shù)可以是相同的

              C.兩個(gè)窗口,他們的窗口句柄和窗口處理函數(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ù)器的情況下,下面描述錯(cuò)誤的是”該防火墻能夠(   )”.

              A.使公司員工只能訪問Internet上與其業(yè)務(wù)聯(lián)系的公司的IP地址.

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

              C.使員工不能直接訪問FTP服務(wù)器端口號(hào)為21的FTP地址.

              D.僅允許公司中具有某些特定IP地址的計(jì)算機(jī)可以訪問外部網(wǎng)絡(luò)

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

              main()

              {

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

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

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

              }

              程序運(yùn)行之后的輸出結(jié)果是:

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

              二.  填空題(共40分)

              本程序從正文文件text.in讀入一篇英文短文,統(tǒng)計(jì)該短文中不同單詞和它的出現(xiàn)次數(shù),并按詞典編輯順序?qū)卧~及它的出現(xiàn)次數(shù)輸出到正文文件word.out中.

              程序用一棵有序二叉樹存儲(chǔ)這些單詞及其出現(xiàn)的次數(shù),一邊讀入一邊建立.然后中序遍歷該二叉樹,將遍歷經(jīng)過的二叉樹上的節(jié)點(diǎn)的內(nèi)容輸出.
            程序中的外部函數(shù)

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

              從與pFile所對(duì)應(yīng)的文件中讀取單詞置入pszWordBuffer,并返回1;若單詞遇文件尾,已無單詞可讀時(shí),則返回0.

              #include <stdio.h>

              #include <malloc.h>

              #include <ctype.h>

              #include <string.h>

              #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 <iostream>

              #include <string>

              #define MAX_NAME_LEN 20

              struct USERINFO

              {

              int nAge;

              char szName[MAX_NAME_LEN];

              };

              void FillUserInfo(USERINFO* parUserInfo)

              {

              stu::cout<<"請(qǐng)輸入用戶的個(gè)數(shù):";

              int nCount=0;

              std::cin>>nCount;

              for(int i=0;i<nCount;i++)

              {

              std::cout<<"請(qǐng)輸入年齡:";

              std::cin>>parUserInfo[i]->nAge;

              std::string strName;
            std::cout<<"請(qǐng)輸入姓名:";

              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è)你在編寫一個(gè)使用多線程技術(shù)的程序,當(dāng)程序中止運(yùn)行時(shí),需要怎樣一個(gè)機(jī)制來安全有效的中止所有的線程?請(qǐng)描述其具體流程.


            posted on 2009-09-23 20:50 life02 閱讀(546) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 筆試
            久久国产香蕉视频| 亚洲va中文字幕无码久久| 青青青国产成人久久111网站| 国产美女久久精品香蕉69| 国产精品99久久精品爆乳| 亚洲成色WWW久久网站| 国产成人无码精品久久久久免费 | 午夜天堂av天堂久久久| 国产精品久久永久免费| 日韩中文久久| 国产精品无码久久四虎| 久久夜色精品国产网站| 亚洲欧美一级久久精品| 久久综合九色综合欧美狠狠| 亚洲伊人久久精品影院| 亚洲精品无码久久久久AV麻豆| 99久久99久久| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 波多野结衣久久一区二区| 国产精品免费看久久久香蕉| 久久亚洲欧美国产精品 | 青青青国产精品国产精品久久久久| 久久久久久精品久久久久| 欧美精品一区二区久久| 久久精品视频免费| 99热成人精品热久久669| 久久久久久久久无码精品亚洲日韩| 思思久久99热只有频精品66| 久久国产成人午夜AV影院| 大美女久久久久久j久久| 亚洲天堂久久精品| 99久久亚洲综合精品网站| 一本久久a久久精品综合夜夜| 精品综合久久久久久888蜜芽| 久久国产精品无码一区二区三区 | 久久夜色撩人精品国产| 久久se这里只有精品| 久久久久久极精品久久久| 天天综合久久一二三区| 麻豆精品久久久久久久99蜜桃| 少妇熟女久久综合网色欲|