C++ primer Plus第二章编程

2-1

#include<iostream>
using namespace std;

int main(){
	cout<<"jjx"<<endl;
	cout<<"HuNan,ChangSha"<<endl;
	return 0;
} 

2-2

#include<iostream>
using namespace std;

int main(){
	float n;
	cin>>n;
	cout<<(n*220)<<"码"<<endl;
	return 0;
} 

2-3

#include<iostream>
using namespace std;
void put_1();
void put_2();

int main(){
	put_1();
	put_2();
	return 0;
} 

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

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

2-4

#include<iostream>
using namespace std;
int put_1(int);

int main(){
	int age;
	cout<<"Enter your age:";
	cin>>age;
	
	put_1(age);
	return 0;
} 

int put_1(int n){
	cout<<(n*12)<<endl;	
}

2-5

#include<iostream>
using namespace std;
int put_1(int);

int main(){
	float Celsius,Fahrebheit;
	cout<<"Please enter a Celsius value:";
	cin>>Celsius;
	Fahrebheit=Celsius*1.8+32.00;
	cout<<Celsius<<" degrees Celsius is "<<Fahrebheit<<" degress Fahrebheit."<<endl;
	
	
	
	return 0;
} 

2-6

#include<iostream>
using namespace std;
float put_1(float);

int main(){
	float light,dis;
	cout<<"Enter the number of light years:";
	cin>>light;
	dis=put_1(light);
	cout<<light<<" light years = "<<dis<<" astronomical units."<<endl;	
	return 0;
} 
float put_1(float l){
	return l*63240;
}

2-7

#include<iostream>
using namespace std;
void put_1(int ,int);

int main(){
	int hour,min;
	cout<<"Enter the number of hour:";
	cin>>hour;
	cout<<"Enter the number of hour:";
	cin>>min;
	put_1(hour,min);

	return 0;
} 
void put_1(int hour,int min)
{
	cout<<hour<<":"<<min<<endl;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值