重读《C++ Primer Plus》,第二章作业

#include<iostream>
int main()
{
	std::cout<<"凤凰台上江自流"<<std::endl<<"Beijing"<<std::endl ; 
}
#include<iostream>
int main()
{
	std::cout<<"please input the long"<<std::endl ;
	int input_long ;
	std::cin>>input_long ;
	int input_distance = input_long*220 ;
	std::cout<<"distance is"<<input_distance<<std::endl ;
	
}
#include<iostream>
void out_put_1() ;
void out_put_2() ;

int main()
{
	out_put_1() ;
	out_put_1() ;
	out_put_2() ;
	out_put_2() ;
}
void out_put_1()
{
	std::cout<<"three blind mice"<<std::endl ;
	return ;
}
void out_put_2(void)
{
	std::cout<<"See how they run"<<std::endl ;
	return ;
}
#include<iostream>
int main()
{
	std::cout<<"please enter your age"<<std::endl ;
	int your_age ;
	std::cin>>your_age ;
	int your_month ;
	your_month = your_age*12 ;
	std::cout<<your_month<<std::endl ;
#include<iostream>
double change_degree(double a) ;
int main()
{
	std::cout<<"please enter a Celsius degree"<<std::endl ;
	int Celsius_degree ;
	std::cin>>Celsius_degree ;
	double Fah_degree  ;
	Fah_degree = change_degree(Celsius_degree) ;
	std::cout<<Fah_degree ;
}
double change_degree(double a)
{
	int result ;
	result = a*1.8 +32 ;
	return result ;
}
#include<iostream>
double trans_distance(double light_year) ;//实现光年和距离的转换
int main()
{
	std::cout<<"please input a light_year"<<std::endl ;
	double light_year ;
	std::cin>>light_year ;
	double distance ;
	distance  = trans_distance(light_year) ;
	std::cout<<"now we got the distance"<<std::endl ;
	std::cout<<distance<<std::endl ;	
}

double trans_distance(double light_year)
{
	int distance ;
	distance = 63240*light_year ;
	return distance ;
}
#include<iostream>
void cout_time(int hour ,int minite) ;//用于按时钟的形式输出某个时间
int main()
{
	int hour ;
	int minite ;
	std::cout<<"Please input the hour and the minite"<<std::endl ;
	std::cin>>hour>>minite ;
	cout_time(hour ,minite) ;
}
void cout_time(int hour ,int minite)
{
	std::cout<<hour<<":"<<minite<<std::endl ;
	return ;
}

猜你喜欢

转载自blog.csdn.net/weixin_42222917/article/details/83451289