- 博客(0)
- 资源 (1)
空空如也
C++ Primer Plus(第五版)习题解答和例题代码
C++ Primer Plus(第五版)习题解答和例题代码。
样例参考如下:
Solutions for Programming Exercises in C++ Primer Plus, 5th Edition
Chapter 2
// pe2-2.cpp
#include <iostream>
int main(void)
{
using namespace std;
cout << "Enter a distance in furlongs: ";
double furlongs;
cin >> furlongs;
double feet;
feet = 220 * furlongs;
cout << furlongs << " furlongs = "
<< feet << " feet\n";
return 0;
}
// pe2-3.cpp
#include <iostream>
using namespace std;
void mice();
void run();
int main()
{
mice();
mice();
run();
run();
return 0;
}
void mice()
{
cout << "Three blind mice\n";
}
void run()
{
cout << "See how they run\n";
}
// pe2-4.cpp
#include <iostream>
double C_to_F(double);
int main()
{
using namespace std;
cout << "Enter a temperature in Celsius: ";
double C;
cin >> C;
double F;
F = C_to_F(C);
cout << C << " degrees Celsius = "
<< F << " degrees Fahrenheit\n";
return 0;
}
double C_to_F(double temp)
{
return 1.8 * temp + 32.0;
}
2012-02-22
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人