[C++ Primer Plus第六版]第2章

1.
#include<iostream>
using namespace std;
int main()
{
	cout << "my name is qing" << endl;
	cout << "my address is guangzhou" << endl;
	return 0;
}

2.

#include<iostream>
using namespace std;
int main()
{
	int n;
	cout << "输入一个距离:";
	cin >> n;
	cout << n * 220<<"码" << endl;
	return 0;
}

3.

#include<iostream>
using namespace std;
void display1();
void display2();
int main()
{
	display1();
	display1();
	display2();
	display2();
	return 0;
}

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

void display2()
{
	cout << "See how they run" << endl;
}

4.

#include<iostream>
using namespace std;
int main()
{
	int n=0;
	cout << "enter your age:";
	cin >> n;
	cout << n * 12 << "months" << endl;
	return 0;
}

5.

#include<iostream>
using namespace std;
int main()
{
	int n=0;
	cout << "Please enter a Celsius value:";
	cin >> n;
	cout << n << "degrees Celsius value is " << n*9/5+32 << endl;
	return 0;
}

6.

#include<iostream>
using namespace std;
int main()
{
	double n=0;
	cout << "Enter the number of light years:";
	cin >> n;
	cout << n << " light night = " << n*63240 << " astronmical units" << endl;
	return 0;
}

7.

#include<iostream>
using namespace std;
void display1(int, int);
int main()
{
	int n = 0;
	int m = 0;
	cout << "Enter the number of hour:";
	cin >> n;
	cout << "Enter the number of minutes:";
	cin >> m;
	display1(n, m);
	return 0;
}

void display1(int x, int y)
{
	cout << "Time: " << x << ":" << y <<endl;
}

猜你喜欢

转载自blog.csdn.net/daisy_fight/article/details/80443445
今日推荐