C++ Primer Plus第二章课后编程答案

#include <iostream>
#include <climits>
using namespace std;
void ex1();
void ex2();
void ex3_1();
void ex3_2();
void ex4();
double ex5(double);
double ex6(double);
void ex7(int, int);
int main()
{
//	using namespace std;
/*	cout << "Come up and C++ me some time.";
	cout << endl;
	cout << "You won't regret it!" << endl;*/
	
//	ex1();
//	ex2();
/*	ex3_1();
	ex3_1();
	ex3_2();
	ex3_2();*/
//	ex4();
/*	double temp;
	cout << "Please enter a Celsius value: ";
	cin >> temp;
	cout << endl << temp << " degrees Celsius is ";
	temp = ex5(temp);
	cout << temp << " degrees Fahrenheit." << endl;
	cin.get();*/
/*	double n;
	cout << "Enter the number of light years: ";
	cin >> n;
	cout << endl << n;
	n = ex6(n);	
	cout << " light years = " << n << " astronomical units." << endl;
	cin.get();
	cin.get();*/
/*	int h, m;
	cout << "Enter the number of hours: ";
	cin >> h;
	cout << endl << "Enter the number of minutes: ";
	cin >> m;
	cout << endl;
	ex7(h, m);
	cin.get();
	cin.get();*/
	int n_int = INT_MAX;
	char alarm = '\a';
	wchar_t bob = L'P';
	cout << "int is " << sizeof (int) << " bytes" << endl;
	cout << "int is " << sizeof n_int- 2<< "bytes" << endl;
	cout << alarm<<alarm<<endl;
	cout << '\u222b'<<endl ;
	wcout << bob;
	cin.get();
	return 0;
}
void ex1()
{
	cout << "姓名:雨珂" << endl << "地址:北京" << endl;
	cin.get();
}
void ex2()
{
	int n;
	cout << "long:";
	cin >> n;
	cout << endl;
	n = n * 220;
	cout << "yard:" << n << endl;
	cin.get();
	cin.get();
}
void ex3_1()
{
	cout << "Three blind mice" << endl;
}
void ex3_2()
{
	cout << "See how they run" << endl;
}
void ex4()
{
	int n;
	cout << "Enter your age:";
	cin >> n;
	cout << endl;
	n = n * 12;
	cout << "month:" << n << endl;
}
double ex5(double n)
{
	n = 1.8*n + 32;
	return n;
}
double ex6(double n)
{
	n = n * 63240;
	return n;
}
void ex7(int h, int m)
{
	cout << "Time: " << h << ":" << m << endl;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值