C++ Primer plus 第二章课后编程练习

第二章课后编程练习

18 //第二章课后编程练习1
#include <iostream>
using namespace std;

int main()
{
	cout << "my name is : " << "wang ming\n";
	cout << "my address: " << "dalian";
	cin.get();
	return 0;
}


19 //第二章课后编程练习2
#include <iostream>
using namespace std;

int main()
{
	int n;
	double sum;
	cin >> n;
	sum = n * 220;
	cout << n << " long is " << sum << "码";

	cin.get();
	return 0;
}

20 //第二章课后编程练习3
#include <iostream>
using namespace std;
void c1(void);
void c2(void);
int main()
{
	c1();
	c1();
	c2();
	c2();
	cin.get();
	return 0;
}

void c1(void)
{
	cout << "Three blind mice\n";
}
void c2(void)
{
	cout << "see how they run\n";
}

21//第二章课后编程练习4
#include <iostream>
using namespace std;

int main()
{
	int n;
	int mouth;
	cout << "enter your age :";
	cin >> n;
	mouth = n * 12;
	cout << mouth;
	cin.get();
	cin.get();
	return 0;
}

22 //第二章课后编程练习5
#include <iostream>
using namespace std;
double c1(double n1);
int main()
{
	double n;
	cout << "Place enter a Celsius value: ";
	cin >> n;
	cout << n << " degrees Celsius is " << c1(n) << " degrees Fahrenheit, ";
	cin.get();
	cin.get();
	return 0;
}

double c1(double n1)
{
	double fahre;
	fahre = 1.8 * n1 + 32;
	return fahre;
}
23//第二章课后编程练习6
#include <iostream>
using namespace std;
double c1(double n1);
int main()
{
	double n;
	cout << " enter a number of light years: ";
	cin >> n;
	cout << n << " light year =  " << c1(n) << " units, ";
	cin.get();
	cin.get();
	return 0;
}

double c1(double n1)
{
	double fahre;
	fahre = n1 * 63240;
	return fahre;
}
24//第二章课后编程练习7
#include <iostream>
using namespace std;
void c1(int n1, double n2);
int main()
{
	int n1;
	double n2;
	cout << " enter a number of hours: ";
	cin >> n1;
	cout << " enter a number of minutes: ";
	cin >> n2;
	cout << endl;
	c1(n1, n2);
	cin.get();
	cin.get();
	return 0;
}
void c1(int n1, double n2)
{
	cout << "Time:" << n1 << ":" << n2;
}

    在这里插入代码片

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值