精品一区二区中文在线,无遮挡h肉动漫在线观看,国产99视频精品免视看9,成全免费高清大全

創新工場校園招聘筆試試題

時間:2024-08-08 15:43:53 資料大全 我要投稿
  • 相關推薦

創新工場校園招聘筆試試題

   一, 選擇題

創新工場校園招聘筆試試題

  1,求z的結果

  [cpp] view plaincopyprint?

  #define N 3

  #define Y(n) ((N+1)*n)

  z = 2*(N+Y(5+1));

  #define N 3

  #define Y(n) ((N+1)*n)

  z = 2*(N+Y(5+1));

  解答:48

  2,有關多線程,多進程的描述錯誤的是

  A, 子進程獲得父進程的數據空間,堆和棧的復制品

  B, 線程可以與同進程的其他線程共享數據,但是它擁有自己的棧空間且擁有獨立的執行序列

  C, 線程執行開銷小,但是不利于資源管理和保護

  D, 進程適合在SMP機器上進行,而線程則可以跨機器遷移

  解答:D

  3,

  [cpp] view plaincopyprint?

  struct s

  { int x:3;

  int y:4;

  int z:5;

  double a;

  }

  struct s

  { int x:3;

  int y:4;

  int z:5;

  double a;

  }

  求sizeof(s)

  解答:

  16

  :是取位的作用,前三個變量是為兩個字節,最后double變量是8個字節,

  結構體以8字節對齊,則為16字節,

創新工場校園招聘筆試試題

  4,序列{2,1,4,9,8,10,6,20}是某排序算法第二輪排序的結果,則該算法只能是

  A快速排序 B冒泡排序

  C選擇排序 D插入排序

  解答:A

  5,我們需要監聽一個事件狀態,讓它在狀態發生改變時主動發出通知,請問需要哪種設計模式?

  A裝飾者模式 B建造者模式

  C創新工場模式 D觀察者模式

  解答:D

  6,有2012瓶礦泉水,其中有一瓶有毒,請問需要多少只老鼠才能一次性找到有毒的礦泉水?

  解答:11只

  二, 問答題

  1, 有0-n這n+1個數,但是其中丟了一個數,請問如何找出丟了哪個數?

  解答:

  求這n個數的sum,然后計算n(n+1)/2-sum可得。

  2, 解釋

  [cpp] view plaincopyprint?

  #typedef char (*func)(int,char*)

  #typedef char (*func)(int,char*)

  解答:

  定義了一個函數指針的數據類型;

  該數據類型可以用來定義函數指針;

  定義的函數指針指向的函數的參數為

  [cpp] view plaincopyprint?

  (int,char*)

  (int,char*)

  返回值為char型。

  3, 求輸出結果

  [cpp] view plaincopyprint?

  int a[2][2][3]= { {{1,2,3},{4,5,6}},{{7,8,9},{10,11,12}}};

  int *ptr=(int *)(&a+1);

  printf(“%d %d”, *(int*)(a+1), *(ptr-1));

  int a[2][2][3]= { {{1,2,3},{4,5,6}},{{7,8,9},{10,11,12}}};

  int *ptr=(int *)(&a+1);

  printf(“%d %d”, *(int*)(a+1), *(ptr-1));

  解答:

  7 12 (已修定)

  考察多級指針,一定要明確指針指向的是什么,才能知道它加1后跳過了多少字節。

  &a是個四級指針,指向的是a這樣的數組,所以它加1,就會跳過整個數組。

  4,求輸出結果

  [cpp] view plaincopyprint?

  #include

  using namespace std;

  class A

  {

  public:

  virtual void print()

  { cout << "A::print()" <

  };

  class B: public A

  {

  public:

  virtual void print()

  { cout << "B::print()" <

  };

  class C: public A

  {

  public:

  virtual void print()

  { cout << "C::print()" <

  };

  void print(A a)

  {

  a.print();

  }

  void main()

  {

  A a,*aa,*ab,*ac;

  B b;

  C c;

  aa=&a;

  ab=&b;

  ac=&c;

  a.print();

  b.print();

  c.print();

  aa->print();

  ab->print();

  ac->print();

  print(a);

  print(b);

  print(c);

  }

  #include

  using namespace std;

  class A

  {

  public:

  virtual void print()

  { cout << "A::print()" <

  };

  class B: public A

  {

  public:

  virtual void print()

  { cout << "B::print()" <

  };

  class C: public A

  {

  public:

  virtual void print()

  { cout << "C::print()" <

  };

  void print(A a)

  {

  a.print();

  }

  void main()

  {

  A a,*aa,*ab,*ac;

  B b;

  C c;

  aa=&a;

  ab=&b;

  ac=&c;

  a.print();

  b.print();

  c.print();

  aa->print();

  ab->print();

  ac->print();

  print(a);

  print(b);

  print(c);

  }

  解答:

  A::print();

  B::print();

  C::print();

  A::print();

  B::print();

  C::print();

  A::print();

  A::print();

  A::print();

  三,算法編程題

  1,有1分,2分,5分,10分四種硬幣,每種硬幣數量無限,給定n分錢,求有多少種組合可以組合成n分錢?

  解答:

  思路:

  ①,四層循環

  ②,使用回溯法在空間中搜索

  代碼為思路2:

  [cpp] view plaincopyprint?

  // chuangxingongchan.cpp : 定義控制臺應用程序的入口點。

  //

  #include "stdafx.h"

  #include

  #include

  using namespace std;

  int count=0;

  int Target=0;

  int coin[4]={1,2,5,10};

  int total=0;

  vector solution;

  void dfs(int index)

  {

  if( total == Target )

  {

  count++;

  cout << count <<":" ;

  for( int i=0; i<(int)solution.size(); i++)

  {

  cout << solution[i]<<" ";

  }

  cout << endl;

  return;

  }

  if( total > Target )

  return;

  for( int i=index; i<4; i++)

  {

  total += coin[i];

  solution.push_back( coin[i] );

  dfs(i);

  solution.pop_back();

  total -=coin[i];

  }

  }

  int _tmain(int argc, _TCHAR* argv[])

  {

  while(1)

  {

  count=0;

  cin >> Target;

  dfs(0);

  cout << count <

  }

  return 0;

  }

  // chuangxingongchan.cpp : 定義控制臺應用程序的入口點,

資料共享平臺

創新工場校園招聘筆試試題》(http://salifelink.com)。

  //

  #include "stdafx.h"

  #include

  #include

  using namespace std;

  int count=0;

  int Target=0;

  int coin[4]={1,2,5,10};

  int total=0;

  vector solution;

  void dfs(int index)

  {

  if( total == Target )

  {

  count++;

  cout << count <<":" ;

  for( int i=0; i<(int)solution.size(); i++)

  {

  cout << solution[i]<<" ";

  }

  cout << endl;

  return;

  }

  if( total > Target )

  return;

  for( int i=index; i<4; i++)

  {

  total += coin[i];

  solution.push_back( coin[i] );

  dfs(i);

  solution.pop_back();

  total -=coin[i];

  }

  }

  int _tmain(int argc, _TCHAR* argv[])

  {

  while(1)

  {

  count=0;

  cin >> Target;

  dfs(0);

  cout << count <

  }

  return 0;

  }

  2,馬戲團里有個疊羅漢的表演,為了便于美觀,下面的人身高和體重都要大于上面的人。現在知道n個演員的身高和體重,請問最多能疊多少層?

  解答:

  思路:

  首先生成一個有向圖,用連接矩陣的方式來表示。

  map[i][j]==1表示第i個人上面可以放第j個人。

  然后開始對每個人進行深度搜索,這個圖中不可能有環。

  所以對于每個人來說就是一棵樹,搜索樹的高度。

  再找出最高的高度即是答案。

  [cpp] view plaincopyprint?

  #include "stdafx.h"

  #include

  #include

  #include

  #include

  using namespace std;

  int N=0;

  double *weight;

  double *height;

  int **map;

  int maxDepth=0;

  vector bestPath;

  int dfs( int index, vector &path )

  {

  int flag=0;

  int depth = 0;

  vector bestPath;

  for( int i=0; i

  {

  if( map[index][i] != 0)

  {

  flag = 1;

  vector tPath;

  int t = dfs(i, tPath);

  if( t > depth )

  {

  path = tPath;

  depth = t;

  }

  }

  }

  if( flag==0 )

  {

  path.clear();

  path.push_back(index);

  return 1;

  }

  else

  {

  // path = bestPath;

  path.push_back(index);

  return depth+1;

  }

  }

  void CreateMap()

  {

  map = new int*[N];

  for( int i=0; i

  {

  map[i] = new int [N];

  memset( map[i], 0, N*sizeof(int) );

  }

  for( int i=0; i

  {

  for( int j=0; j

  {

  if( weight[j]

  map[i][j]=1;

  }

  }

  }

  void CreateData()

  {

  ofstream out( "in.txt" );

  int N = 30;

  out << N <

  for( int i=0; i

  out << rand() << " ";

  out << endl;

  for( int i=0; i

  out << rand() << " ";

  }

  int main()

  {

  CreateData();

  freopen( "in.txt", "r", stdin );

  cout << "Please input N:" <

  cin >> N;

  height = new double[N];

  weight = new double[N];

  for( int i=0; i

  cin >> height[i];

  for( int i=0; i

  cin >> weight[i];

  CreateMap();

  int depth=0;

  for(int i=0; i

  {

  vector tPath;

  int t=dfs(i,tPath);

  if( t>depth )

  {

  bestPath = tPath;

  depth = t;

  }

  }

  cout << depth <

  for( int i=0; i<(int)bestPath.size(); i++)

  {

  cout << height[bestPath[i]]<< " " << weight[bestPath[i]]<

  }

  return 0;

  }

【創新工場校園招聘筆試試題】相關文章:

創新工場校招筆試題11-03

小米校園招聘筆試題11-03

校園招聘筆試題目08-27

網易校園招聘筆試題10-06

新浪校園招聘筆試題05-26

58同城校園招聘筆試題10-06

金山校園招聘Java筆試題07-24

海康威視校園招聘筆試題05-30

百度校園招聘筆試題精選07-22

淘寶校園招聘會筆試題10-24