(二十二)第二章最后的编程练习答案(七合一版)

书是:C++ Primer Plus  第6版  中文版

七合一答案如下:


#include<iostream>

using namespace std;
char32_t first(void);
char32_t last(void);
double fahrenheit(int);
double guangnian(double);
void time(int, int);

int main()
{
	cout << "my name is 王冬" << endl;
	cout << "my phone number is 13259991209" << endl;

	cout << "————————————————————————————————————" << endl;

	int long1;
	cout << "请输入一个以long为单位的距离,这里将自动帮你转换为以码为单位的距离。" << endl;
	cout << "请输入: ";
	cin >> long1;
	cout << long1 << "long = " << long1*220 << " 码。" << endl;

	cout << "————————————————————————————————————" << endl;

	first();
	first();
	last();
	last();
	
	cout << "————————————————————————————————————" << endl;

	int age;
	cout << "Enter your age: ";
	cin >> age;
	cout << "Your age have " << age * 12 << " month." << endl;

	cout << "————————————————————————————————————" << endl;

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

	cout << "————————————————————————————————————" << endl;

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

	cout << "————————————————————————————————————" << endl;

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

	cout << "————————————————————————————————————" << endl;


	system("pause");
	return 0;
}

char32_t first()
{
	cout << "Three blind me" << endl;
	return 0;
}

char32_t last()
{
	cout << "see how they run" << endl;
	return 0;
}

double fahrenheit(int a)
{
	int c;
	c = 1.8*a + 32.0;
	return c;
}

double guangnian(double a)
{
	return a * 63240;
}

void time(int a, int b)
{
	cout <<"Time: "<< a << ":" << b << endl;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值