课后编程题(2章)

本章总结

课后编程题(2章)_第1张图片

 

 

 

题目预览

课后编程题(2章)_第2张图片

 

 

 课后编程题(2章)_第3张图片

 

 

 题目解答

#include "stdafx.h"
#include

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	cout << "my name is linda!"<<" my address is XXX"< 
 

  运行结果

 

 

 1 #include "stdafx.h"
 2 #include
 3 
 4 using namespace std;
 5 
 6 int _tmain(int argc, _TCHAR* argv[])
 7 {
 8     int dis;
 9     dis = 0;
10 
11     cout << "请输入距离:"<<endl;
12     cin >> dis;
13     cout << "您输入距离是:" << dis << "long" << endl;
14     cout << "转换后是:" << dis*220 << "" << endl;
15     system("pause");
16     return 0;
17 }

运行结果

课后编程题(2章)_第4张图片

 

课后编程题(2章)_第5张图片

 

 

 

 1 #include "stdafx.h"
 2 #include
 3 
 4 using namespace std;
 5 
 6 void func1();
 7 void func2();
 8 
 9 int _tmain(int argc, _TCHAR* argv[])
10 {
11     func1();
12     func1();
13     func2();
14     func2();
15     system("pause");
16     return 0;
17 }
18 
19 void func1(){
20     cout << "Three blind mice" << endl;
21 }
22 
23 void func2(){
24     cout << "See how they run" << endl;
25 }

运行结果

课后编程题(2章)_第6张图片

 

 

 

 

 

 

 1 #include "stdafx.h"
 2 #include
 3 
 4 using namespace std;
 5 
 6 
 7 
 8 int _tmain(int argc, _TCHAR* argv[])
 9 {
10     int age = 0;
11     cout << "请输入你的年龄:" << endl;
12     cin >> age;
13     cout << "换算成月份:" << age*12 << endl;
14 system("pause");
15     return 0;
16 }

运行结果

课后编程题(2章)_第7张图片

 

 

 

 

 

 

 #include "stdafx.h"
 2 #include
 3 
 4 using namespace std;
 5 
 6 
 7 double Fahrenheit(int temp);
 8 int _tmain(int argc, _TCHAR* argv[])
 9 {
10     int temp = 0;
11     cout << "Please enter a Celsius value" << endl;
12     cin >> temp;
13     cout << temp << " degrees Celsius is " << Fahrenheit(temp) << " degrees Fahrenheit " << endl;
14     system("pause");
15     return 0;
16 }
17 
18 double Fahrenheit(int temp){
19     return 1.8*temp + 32;
20 }

运行结果

 

 

 

 1 #include "stdafx.h"
 2 #include
 3 
 4 using namespace std;
 5 
 6 
 7 long LighYear(double temp);
 8 int _tmain(int argc, _TCHAR* argv[])
 9 {
10     double temp = 0;
11     cout << "Enter the number of light years:" << endl;
12     cin >> temp;
13     cout << temp << " light years = " << LighYear(temp) << " astronomical units " << endl;
14     system("pause");
15     return 0;
16 }
17 
18 long LighYear(double temp){
19     return temp*265608;
20 }

运行结果

 

课后编程题(2章)_第8张图片

 

 

 

 

 1 #include "stdafx.h"
 2 #include
 3 
 4 using namespace std;
 5 
 6 
 7 void LighYear(int hours, int minute);
 8 int _tmain(int argc, _TCHAR* argv[])
 9 {
10     int h,m;
11     cout << "Enter the number of hours:" << endl;
12     cin >> h;
13     cout << "Enter the number of minutes:" << endl;
14     cin >> m;
15     LighYear(h,m);
16     system("pause");
17     return 0;
18 }
19 
20 void LighYear(int hours, int minute){
21     cout << "Time " << hours << ":" << minute << endl;
22 }

运行结果

 

课后编程题(2章)_第9张图片

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#include"stdafx.h"

#include

 

usingnamespace std;

 

 

 

int_tmain(intargc, _TCHAR* argv[])

{

    int age = 0;

    cout << "请输入你的年龄:" << endl;

    cin >> age;

    cout << "换算成月份:" << age*12 << endl;

system("pause");

    return 0;

}

你可能感兴趣的:(课后编程题(2章))