Accelerated C++:通过示例进行编程实践——练习解答(第15章)

我的Github地址:https://github.com/CNhoward/Accerlerated-C-plus-plus

本节习题与11、12、13、14等都相关,相关习题解决也基本相同,故可以参考前面章节,本节习题代码见Github。

15-0. Compile, execute, and test the programs in this chapter.

Ans:见Github

15-1. Test your system by writing a program that executes

Picture p = // some initial starting picture
Picture q = frame(p);
Picture r = hcat(p, q) ;
Picture s = vcat(q, r);
cout  <<  frame(hcat(s, vcat(r, q))) << endl;

Ans:见Github

15-2. Reimplement the Frame_Pic class so that the frame uses three different characters: one for the corners, another for the top and bottom borders, and a third for the side borders.

Ans:见Github

15-3. Give users the option to specify what characters to use for these border characters.

Ans:见Github

15-4. Add an operation to reframe a Picture, which changes the frame characters. The operation should change all of the frames in the interior picture.

Ans:见Github

15-5. Reimplement HCat_Pic so that when pictures of a different size are concatenated, the shorter one is centered in the space consumed by the longer one. That is, if we horizontally concatenate two pictures, one of which is four lines long and the other is two lines long, the first and last rows of the output picture will be blank on the side of the shorter picture. What can we now conclude about the necessity of the tests betweenrow and 0.

Ans:见Github

15-6. The Vec and str classes that we developed in Chapters 11 and 12 are powerful enough to be used to implementPictures. Reimplement the material in this chapter to use Vec<str> instead ofvector<string>, and test your implementation.

Ans:见Github

你可能感兴趣的:(编程,C++,C++,Accelerated,Accelerated,C++习题解答,通过示例进行编程实践)