- 相關(guān)推薦
創(chuàng)新工場(chǎng)筆試題2014年校園招聘
時(shí)間:2012年9月27日 地點(diǎn):鼎好大廈10層
考試時(shí)長(zhǎng):1小時(shí)
一, 選擇題
1,求z的結(jié)果
[cpp] view plaincopyprint?
#define N 3#define Y(n) ((N+1)*n)z = 2*(N+Y(5+1));
解答:48
2,有關(guān)多線程,多進(jìn)程的描述錯(cuò)誤的是
A, 子進(jìn)程獲得父進(jìn)程的數(shù)據(jù)空間,堆和棧的復(fù)制品
B, 線程可以與同進(jìn)程的其他線程共享數(shù)據(jù),但是它擁有自己的?臻g且擁有獨(dú)立的執(zhí)行序列
C, 線程執(zhí)行開(kāi)銷小,但是不利于資源管理和保護(hù)
D, 進(jìn)程適合在SMP機(jī)器上進(jìn)行,而線程則可以跨機(jī)器遷移
解答:D
3,
[cpp] view plaincopyprint?
struct s{ int x:3; int y:4; int y:5; double a;}
求sizeof(s)
解答:20或者24;和平臺(tái)有關(guān)。
4,序列{2,1,4,9,8,10,6,20}是某排序算法第二輪排序的結(jié)果,則該算法只能是
A快速排序 B冒泡排序
C選擇排序 D插入排序
解答:A
5,我們需要監(jiān)聽(tīng)一個(gè)事件狀態(tài),讓它在狀態(tài)發(fā)生改變時(shí)主動(dòng)發(fā)出通知,請(qǐng)問(wèn)需要哪種設(shè)計(jì)模式?
A裝飾者模式 B建造者模式
C創(chuàng)新工場(chǎng)模式 D觀察者模式
解答:D
6,有2012瓶礦泉水,其中有一瓶有毒,請(qǐng)問(wèn)需要多少只老鼠才能一次性找到有毒的礦泉水?
解答:11只
二, 問(wèn)答題
1, 有0-n這n+1個(gè)數(shù),但是其中丟了一個(gè)數(shù),請(qǐng)問(wèn)如何找出丟了哪個(gè)數(shù)?
解答:
求這n個(gè)數(shù)的sum,然后計(jì)算n(n+1)/2-sum可得。
2, 解釋
[cpp] view plaincopyprint?
#typedef char (*func)(int,char*)
解答:
定義了一個(gè)函數(shù)指針的數(shù)據(jù)類型;
該數(shù)據(jù)類型可以用來(lái)定義函數(shù)指針;
定義的函數(shù)指針指向的函數(shù)的參數(shù)為
[cpp] view plaincopyprint?
(int,char*)
返回值為char型。
3, 求輸出結(jié)果
[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));
解答:
12 7
考察多級(jí)指針,一定要明確指針指向的是什么,才能知道它加1后跳過(guò)了多少字節(jié)。
&a是個(gè)四級(jí)指針,指向的是a這樣的數(shù)組,所以它加1,就會(huì)跳過(guò)整個(gè)數(shù)組。
4,求輸出結(jié)果
[cpp] view plaincopyprint?
#include
using namespace std;class A{public: virtual void print() { cout << "A::print()" 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分四種硬幣,每種硬幣數(shù)量無(wú)限,給定n分錢,求有多少種組合可以組合成n分錢?
解答:
思路:
、伲膶友h(huán)
、,使用回溯法在空間中搜索
代碼為思路2:
[cpp] view plaincopyprint?
// chuangxingongchan.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。//#include "stdafx.h"#include
#includeusing namespace std;int count=0;int Target=0;int coin[4]={1,2,5,10};int total=0;vectorsolution;void dfs(int index){ if( total == Target ) { count++; cout << count <<":" ; for( int i=0; i<(int)solution.size(); i++) { cout << solution<<" "; } cout << total=""> Target ) return; for( int i=index; i<4; i++) { total += coin; solution.push_back( coin ); dfs(i); solution.pop_back(); total -=coin; }}int _tmain(int argc, _TCHAR* argv[]){ while(1) { count=0; cin >> Target; dfs(0); cout << count <
2,馬戲團(tuán)里有個(gè)疊羅漢的表演,為了便于美觀,下面的人身高和體重都要大于上面的人,F(xiàn)在知道n個(gè)演員的身高和體重,請(qǐng)問(wèn)最多能疊多少層?
解答:
思路:
首先生成一個(gè)有向圖,用連接矩陣的方式來(lái)表示。
map[j]==1表示第i個(gè)人上面可以放第j個(gè)人。
然后開(kāi)始對(duì)每個(gè)人進(jìn)行深度搜索,這個(gè)圖中不可能有環(huán)。
所以對(duì)于每個(gè)人來(lái)說(shuō)就是一棵樹(shù),搜索樹(shù)的高度。
再找出最高的高度即是答案。
[cpp] view plaincopyprint?
#include "stdafx.h"#include
#include#include#includeusing namespace std;int N=0;double *weight;double *height;int **map;int maxDepth=0;vectorbestPath;int dfs( int index, vector&path ){ int flag=0; int depth = 0; vectorbestPath; for( int i=0; i 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 N; height = new double[N]; weight = new double[N]; for( int i=0; i> height; for( int i=0; i> weight; CreateMap(); int depth=0; for(int i=0; idepth ) { bestPath = tPath; depth = t; } } cout << depth <
【創(chuàng)新工場(chǎng)筆試題校園招聘】相關(guān)文章:
創(chuàng)新工場(chǎng)的幾道算法面試題11-16
創(chuàng)新工場(chǎng)2014筆試算法題匯總附答案11-16
人人校園招聘筆試題目11-08
唯品會(huì)校園招聘筆試題12-01
卓越亞馬遜校園招聘開(kāi)放筆試題11-21
2015國(guó)壽校園招聘筆試題02-21
校園招聘面試題及答題技巧11-19
2015年快的打車校園招聘筆試題02-21
建行校園招聘柜員崗位筆試題目11-10