《C++ primer plus 英文版 第六版》娓娓道来。这个是上下分册。而且,出版时间是最新的2015年,买回来发现网上的勘误基本都被纠正过来了,极个别错误没有影响到理解,好哎!而且发现遣词造句特别简单,读着也顺畅。
电子版(PDF):
C++ Primer Plus Sixth Edition.pdf密码:910h
C++ Primer.Plus 第6版中文版密码:ihsq
Chpter Review 的解答参考书的 Appendix J
Programming Exercises 主要参考了下边的帖子:
C++-primer-plus(第6版)中文版编程练习答案(完全版).pdf密码:20rn
C++-Primer-Plus(第六版)编程习题解答(不完全版).doc密码:hxzs
charlesdong
下文 Programming Exercises 部分的代码亲自敲过,可运行。环境:macOS 下 Xcode

Chapter Review

Programming Exercises

1

#include <iostream>

int main()
{
    using namespace std;

    cout << "Name: NaRiSu;\n"
         << "Address: BeiJing;" << endl;

    return 0;
}

2

#include <iostream>

int main()
{
    using namespace std;

    int furlong;
    cin >> furlong;
    cout << furlong << " furlong(s) = "
         << 220 * furlong << " yard(s)" << endl;

    return 0;
}

3

#include <iostream>
void f1();
void f2();

using namespace std;

int main()
{
    f1();
    f1();
    f2();
    f2();

    return 0;
}

void f1()
{
    cout << "Three blind mice" << endl;
}

void f2()
{
    cout << "See how they run\n"; // 也可以用f1()函数中的endl形式。

    return; // void f2()表明无返回值,故可以这样写;也可以如f1()不写return语句。
}

4

#include <iostream>

int main()
{
    using namespace std;

    cout << "Enter your age: ";
    int age;
    cin >> age;
    cout << "Your age in months is " << 12 * age << "." << endl;

    return 0;
}

5

#include <iostream>
double fahrenheit(double);

int main()
{
    using namespace std;

    cout << "Please enter a Celsius value: ";
    int celsius;
    cin >> celsius;
    cout << celsius << " degrees Celsius is "
         << fahrenheit(celsius) << " degrees Fahrenheit." << endl;

    return 0;
}

double fahrenheit(double n)
{
    return 1.8 * n + 32.0;
}

6

#include <iostream>
double astronomical(double);

int main()
{
    using namespace std;

    cout << "Enter the number of light years: ";
    double light;
    cin >> light;
    cout << light << " light years = "
         << astronomical(light) << " astronomical units." << endl;

    return 0;
}

double astronomical(double n)
{
    return 63240 * n;
}

7

#include <iostream>
void f(int, int);

int main()
{
    using namespace std;

    cout << "Enter the number of hours: ";
    int hour;
    cin >> hour;
    cout << "Enter the number of minutes: ";
    int minute;
    cin >> minute;
    f(hour, minute);

    return 0;
}

void f(int h, int m)
{
    using namespace std;

    cout << "Time: " << h << " : " << m << endl;
}
05-11 16:57