<dfn id="w48us"></dfn><ul id="w48us"></ul>
  • <ul id="w48us"></ul>
  • <del id="w48us"></del>
    <ul id="w48us"></ul>
  • c++一些筆試題目和整理的答案

    時間:2024-06-20 10:21:32 綜合指導 我要投稿
    • 相關推薦

    c++一些筆試題目和整理的答案

      NO1

    c++一些筆試題目和整理的答案

      Below is usual way we find one element in an array

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

      {

      const int* p = array;

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

      {

      if(*p == x)

      {

      return p;

      }

      ++p;

      }

      return 0; }

      In this case we have 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++)

      {

      if(*p == x)

      {

      return p;

      }

      ++p;

      }

      return 0; }

      NO2

      Give 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() { [] stackPtr ; }

      int push(const T&);

      int pop(T&) ;

      int isEmpty()const { return top == -1 ; }

      int isFull() const { return top == size - 1 ; }

      private:

      int size ; // number of elements on Stack.

      int top ;

      T* stackPtr ;

      } ;

      NO3

      Implement the simplest singleton pattern(initialize if necessary).

      class Singleton {

      public:

      static Singleton* Instance();

      protected:

      Singleton();

      private:

      static Singleton* _instance;

      }

      // Implementation

      Singleton* Singleton::_instance = 0;

      Singleton* Singleton::Instance() {

      if (_instance == 0) {

      _instance = new Singleton;

      }

      return _instance;

      }

      NO4

      1.Jeff and 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才能贏,我先抽得話不可能達到這幾個數,很顯然,只能讓對

      方先抽,也即是先抽的人輸


    【c++一些筆試題目和整理的答案】相關文章:

    C++工程師筆試題目11-25

    報社筆試題目及答案03-23

    筆試的題目和經驗分享11-21

    2024騰訊筆試題目及答案08-21

    游戲策劃筆試題目答案02-25

    口語和筆試題目分享11-21

    筆試的具體題目數和形式02-23

    馬士基的筆試題目和感受11-21

    史上最全軟件筆試題目及答案04-03

    富士康筆試題目及答案03-30

    主站蜘蛛池模板: 97精品国产手机| 久久精品国产欧美日韩| 欧美精品黑人粗大| 97精品国产手机| 日韩精品人成在线播放| 四虎国产精品永久地址99新强| 午夜精品乱人伦小说区| 精品人妻少妇一区二区| 99精品国产高清一区二区麻豆| 亚洲精品WWW久久久久久| 成人一区二区三区精品| 99re66热这里只有精品| 亚洲精品无码永久在线观看你懂的| 亚洲精品高清国产一久久| 国精品无码一区二区三区左线| 亚洲AV日韩精品一区二区三区| 99久久精品免费国产大片| 国产精品电影网| 精品少妇无码AV无码专区| 亚洲一日韩欧美中文字幕欧美日韩在线精品一区二 | 亚洲精品无码国产| 久久国产精品无码网站| 国产视频精品免费视频| 国产91精品一区二区麻豆亚洲 | 在线成人精品国产区免费| 精品久久人人妻人人做精品| 国产精品成人免费观看| 亚洲精品私拍国产福利在线| 老司机69精品成免费视频| 国产亚洲精品一品区99热| 99国产精品久久| 国产成人vr精品a视频| 国产精品无码A∨精品影院| 精品不卡一区二区| 国产人妖乱国产精品人妖| 久久久精品人妻一区二区三区四| 免费精品久久久久久中文字幕| 国产精品主播一区二区| 国产精品午夜福利在线无码| 国模精品一区二区三区| 国产精品一区三区|