c++ primer plus 第六版第二章编程练习答案
来源:互联网 发布:sony 摄像机 网络直播 编辑:程序博客网 时间:2024/04/30 02:02
初学c++,希望大家在看的时候有问题来告诉我,谢谢~
我用的IDE是vs2013。
2.7.1
#include <cstdlib>
#include <iostream>
int main()
{
using namespace std;
cout << "My name is Liu Wei "
<< endl
<< "And my address is Daqing."
<< endl;
system("pause");
return 0;
}
2.7.2
#include <cstdlib>
#include <iostream>
//码的英文是yard
int main()
{
using namespace std;
int distance, yard;
cout << "Input a long and I'll "
<< "tell you how yard is :";
cin >> distance;
yard = 220 * distance;
cout << "The " << distance << " long is "
<< yard << " yard " << endl;
system("pause");
return 0;
}
2.7.3
#include <iostream>
#include <cstdlib>
using namespace std;
void mice();
void run();
int main()
{
mice();
mice();
run();
run();
system("pause");
return 0;
}
void mice()
{
cout << "Three blind mice." << endl;
}
void run()
{
cout << "See how they run." << endl;
}
2.7.4
#include <iostream>
#include <cstdlib>
int mon(int);
int main()
{
using namespace std;
int year, month;
cout << "Enter your age :";
cin >> year;
month = mon(year);
cout << "The month is: " << month << endl;
system("pause");
return 0;
}
int mon(int year)
{
int month;
month = 12 * year;
return month;
}
2.7.5
//摄氏温度(Celsius [ˈselsiəs] temperature)
//华氏度(Fahrenheit ['færənhaɪt])
//华氏温度 = 摄氏温度 × 1.8 + 32
#include <iostream>
#include <cstdlib>
using namespace std;
int change(int Celsius);
int main()
{
int Celsius, Fahrenheit;
cout << "Please enter a Celsius value: ";
cin >> Celsius;
Fahrenheit = change(Celsius);
cout << Celsius << " degrees Celsius is " << Fahrenheit
<< " degrees Fahrenheit" << endl;
system("pause");
return 0;
}
int change(int Celsius)
{
return Celsius * 1.8 + 32;
}
2.7.6
#include <iostream>
#include <cstdlib>
using namespace std;
double change(double light_year);
int main()
{
double light_year, astronomical_units;
cout << "Enter the number of light years: ";
cin >> light_year;
astronomical_units = change(light_year);
cout << light_year << " light years = " << astronomical_units
<< " astronomical units. " << endl;
system("pause");
return 0;
}
double change(double light_year)
{
return 63240 * light_year;
}
2.7.7
#include <iostream>
#include <cstdlib>
using namespace std;
void time(int hours, int minutes);
int main()
{
int hours, minutes;
cout << "Enter the number of hours: ";
cin >> hours;
cout << "Enter the number of minutes: ";
cin >> minutes;
time(hours, minutes);
system("pause");
return 0;
}
void time(int hours, int minutes)
{
cout << "Time: " << hours << ":" << minutes << endl;
}
- C ++ Primer Plus 第六版 第六章编程练习答案
- C++ Primer Plus第六版 第二章 编程练习答案
- c++ primer plus 第六版第二章编程练习答案
- c++.primer.plus第五版第六章编程练习答案
- C ++ Primer Plus 第六版 第七章编程练习答案
- C ++ Primer Plus 第六版 第八章编程练习答案
- C ++ Primer Plus 第六版 第九章编程练习答案
- C ++ Primer Plus 第六版 第十章编程练习答案
- C ++ Primer Plus 第六版 第十一章编程练习答案
- C ++ Primer Plus 第六版 第十二章编程练习答案
- C ++ Primer Plus 第六版 第十三章编程练习答案
- C ++ Primer Plus 第六版 第十七章编程练习答案
- C Primer Plus (第五版) 第六章 编程练习 答案
- C++ Primer Plus第六版 第六章 编程练习答案
- C++primer plus第六版课后编程练习答案2.2
- C++primer plus第六版课后编程练习答案2.3
- C++primer plus第六版课后编程练习答案2.4
- C++primer plus第六版课后编程练习答案2.5
- 利用 Excel封装成OCX 在wxPython窗口中显示、操作
- Google Guava-集合类型
- JavaScript函数的认识
- Android ListView控件的资源回收机制
- code slot - SkipList - 1
- c++ primer plus 第六版第二章编程练习答案
- hdu3374最小表示法+KMP
- 动态分配内存malloc()函数
- sql查处某字段不重复的全部记录
- 解决cmd命令控制台窗口一闪而过运行后就消失的方法
- 常用的MYSQL维护工具介绍
- Android手机刷机介绍
- Eclipse Android SDK无法下载问题不翻墙解决办法
- 在ubuntu14.04上,源码编译安装Mplayer