b) 写一个函数去掉一个字符串中单词间多余的空格,使得相邻两个单词间有且只有一个空格。例如当输入字符串是“Hello!_ _Game_programming_ _world!”时,调用该函数后字符串变为“Hello!_Game_programming_world!”。
c) 假定屏幕的像素宽度为screenWidth,写一个函数计算一个字符串需要分成几行显示。
要求:
1、每行应尽可能多地显示字符,但不能有字符部分或完全显示在屏幕外。超过部分的字符换下一行显示。
2、每个字符的像素宽度不一样,每个字符的像素宽度不一样。用int GetCharWidth(char c)获得每个字符的像素宽度。
5、 把以下段落翻译成中文
a) An integral approach to code documentation is to write the code so that it documents itself.In other words,the code should be naturally readable in such a way as to make it easy to understand .This is accomplished by proper naming conventions and statement formatting.
b) Collections are the data structures that are most easily altered for performance-tuning purposes. Using the correct or most appropriate collection class can improve performance with little change to code. For example, if a large ordered collection has elements frequently deleted or inserted throughout it, it usually can provide better performance if based on a linked list rather than an array. On the other hand, a static(unchanging) collection that needs to be accessed by index performs better with an underlying implementation that is an array.