C++Primer Plus6编程题(第二章)

        看代码就好了,很简单


#include <iostream>
using namespace std;

/*第三题定义的函数*/
void out1() {
	cout << "Three blind mice" << endl;
}
void out2() {
	cout << "see how they run" << endl;
}
void display(int h, int m);
double huashi(double tem);

int main() {
	/*
		1.编写一个c++程序,它显示您的姓名和地址
	*/
	/*cout << "name:" << "Cuit小唐" << endl << "地址:" << "Cuit";
	return 0;*/


	/*
		2.要求用户输入一个以long为单位的距离,然后将它转换为码(一 long 等于 220 码)
	*/

	/*int long1;

	cout << "请输入距离:" << endl;
	cin >> long1;
	long1 = long1 * 220;*/

	/*
		3.使用3个用户定义的函数(包括main()),并生成下面的输出:
		Three blind mice
		Three blind mice
		see how they run
		see how they run

		分别调用两次
	*/
	
	//out1();
	//out1();
	//out2();
	//out2();

	/*编写一个程序,让用户输入其年龄,然后显示这个年龄包含多少个月*/
	//int age,month;
	//cout << "Enter your age:";
	//cin >> age;
	//month = 12 * age;
	//cout << "Your age in months is " << month;

	/*
		5.main调用一个用户自定义函数(以摄氏温度值为参数,并返回相应的华氏度温度值)
			华氏温度 = 1.8  * 摄氏度 + 32.0    */
	/*double tem,hua;
	cin >> tem;
	hua = huashi(tem);
	cout << hua;*/

	/*6.编写函数用户输入小时数和分钟数,将两个值传给void 函数并且输出到控制台*/
	int h, m;
	cin >> h >> m;
	display(h, m);

}

/*第五题定义的函数*/
double huashi(double tem) {
	double con;
	return con = tem * 1.8 + 32.0;
}

/*6*/
void display(int h, int m) {
	cout << h << ":" << m;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值