用户名: 密码: 企业 个人
当前位置:89学习网范文文章招聘应聘笔试2017年海康威视校园招聘笔试题» 正文

2017年海康威视校园招聘笔试题

[05-15 14:50:43]   来源:http://www.89xue.com  笔试   阅读:90
摘要:I am ~Derived()I am ~Base()I am ~Base()11、阅读以下程序并给出执行结果class Bclass{public:Bclass(int i , int j){x = i;y = j;}virtual int fun(){return 0;}protected:int x , y;};class lclass : public Bclass{public:lclass(int i , int j , int k) : Bclass(i , j){z = k;}int fun(){return (x+y+z)/3;}private:int z;};int main(void){lc。
2017年海康威视校园招聘笔试题,标签:笔试范文,http://www.89xue.com

  I am ~Derived()

  I am ~Base()

  I am ~Base()

  11、阅读以下程序并给出执行结果

  class Bclass

  {

  public:

  Bclass(int i , int j)

  {

  x = i;

  y = j;

  }

  virtual int fun()

  {

  return 0;

  }

  protected:

  int x , y;

  };

  class lclass : public Bclass

  {

  public:

  lclass(int i , int j , int k) : Bclass(i , j)

  {

  z = k;

  }

  int fun()

  {

  return (x+y+z)/3;

  }

  private:

  int z;

  };

  int main(void)

  {

  lclass obj(2,4,10);

  Bclass p1 = obj;

  cout<

  Bclass &p2 = obj;

  cout<

  cout<

  Bclass *p3 = &obj;

  cout

  return 0;

  }

  class Bclass

  {

  public:

  Bclass(int i , int j)

  {

  x = i;

  y = j;

  }

  virtual int fun()

  {

  return 0;

  }

  protected:

  int x , y;

  };

  class lclass : public Bclass

  {

  public:

  lclass(int i , int j , int k) : Bclass(i , j)

  {

  z = k;

  }

  int fun()

  {

  return (x+y+z)/3;

  }

  private:

  int z;

  };

  int main(void)

  {

  lclass obj(2,4,10);

  Bclass p1 = obj;

  cout<

  Bclass &p2 = obj;

  cout<

  cout<

  Bclass *p3 = &obj;

  cout

  return 0;

  }输出结果:

  0

  5

  0

  5

  12、如何减少频繁分配内存(malloc或者new)造成的内存碎片?(10分)

  13、请写出strchr的实现(10分)

  函数功能:找出在字符串str中第一次出现字符ch的位置,找到就返回该字符位置的指针(也就是返回该字符在字符串中的地址的位置),找不到就返回空指针(就是NULL)

  const char* strchr(const char* str , char ch)

  const char* strchr(const char* str , char ch)

  {

  char *p = NULL;

  const char* s = str;

  for( ; *s != '\0' ; ++s)

  {

  if(*s == ch)

  {

  p = (char *)s;

  break;

  }

  }

  return p;

  }

  const char* strchr(const char* str , char ch)

  {

  char *p = NULL;

  const char* s = str;

  for( ; *s != '\0' ; ++s)

  {

  if(*s == ch)

  {

  p = (char *)s;

  break;

  }

  }

  return p;

  }

  14、请写出冒泡排序法算法(20分)

  void BubbleSort(int r[] , int n);

  void BubbleSort(int r[] , int n)

  {

  int i , j , temp;

  for(i = 0 ; i < n - 1 ; ++i)

  {

  for(j = 0 ; j < n-i-1 ; ++j)

  {

  if(r[j] > r[j + 1])

  {

  temp = r[j];

  r[j] = r[j + 1];

  r[j + 1] = temp;

  }

上一页  [1] [2] [3] [4] [5] [6]  下一页


Tag:笔试笔试范文招聘应聘 - 笔试