《Cracking the Coding Interview》——第12章:测试——题目5·

2014-04-25 00:41

题目:怎么测试一支笔?(Pen?您老说的是钢笔?)

解法:这种简约而不简单的题目,实在是面试官最喜欢,面试者最头疼的类型了。面试官可以只花三秒,以一种灰常高贵冷艳的语气甩出这道题。然后头疼脑热的就是你了。怎么做呢?Brainstorming,找特征,分解问题,关联问题和特征,然后按规矩解题。我个人觉得这类题其实不是考察创意,而是考察发现问题、分析问题、解决问题的思路是否够清晰,就算解不出来也没事的。

代码:

 1 // 12.5 How would you test a pen?

 2 // Answer:

 3 //    1. A pen uses ink.

 4 //    2. A pen usually writes on paper.

 5 //    3. The volume of ink in the pen is usually small.

 6 //    4. Sometimes when the pen is used for too long, we wash the pen with water and dry it.

 7 //    5. When drawing ink from the ink bottle, we squeeze the ruber tube and releases it to draw the ink up into the pen.

 8 // Above all the things, there are a few things to be tested:

 9 //    1. the ruber tube which contains the ink.

10 //        1.a. is it elastic enough?

11 //    2. a very thin pipe, from which ink flows into the pen.

12 //        2.a. is it easily blocked?

13 //        2.b. does it break easily?

14 //    3. the upper cover, which protects the ruber tube inside it.

15 //        3.a. can the whorl fit tight?

16 //        3.b. is the cover firm enough? does it crack easily?

17 //    4. the tip of the pen, through which the ink flow out.

18 //        4.a. it is actually a pipe, does it block easily?

19 //        4.b. write it on different paper textures, does it write smoothly?

20 //        4.c. it is steel, does it rust easily?

21 int main()

22 {

23     return 0;

24 }

 

你可能感兴趣的:(interview)