C++primer plus第二章练习题

本文档集合展示了五组C++、C#、Python等编程语言的基础实例,涉及面包括数值转换、单位换算、字符串操作、函数和类的使用,以及面向对象编程。同时涵盖了前端开发、后端开发、数据结构与算法等内容。
#include <iostream>

using namespace std;

int main(){
	cout<<"姓名:第三天"<<endl;
	cout<<"居住地:中国苏州"<<endl;

	system("pause");
	return 0;
}
#include <iostream>

using namespace std;

int main(){
	int _long;
	int ma;
	cout<<"请输入一个以long为距离的单位:";
	cin>>_long;

	ma = _long * 220;

	cout<<"共有"<<ma<<"码"<<endl;

	system("pause");
	return 0;
}
#include <iostream>

using namespace std;

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

void s2(){
	cout<<"See how they run"<<endl;
}
int main(){
	s1();
	s1();
	s2();
	s2();
	system("pause");
	return 0;
}
#include <iostream>

using namespace std;

int main(){
	int age;
	int mounth;
	cout<<"Enter your age:";
	cin>>age;

	mounth = age * 12;

	cout<<age<<"岁包含"<<mounth<<"个月"<<endl;

	system("pause");
	return 0;
}
#include <iostream>

using namespace std;

double change(double celsius){

	return 1.8 *celsius +32.0;
}
int main(){
	double celsius;

	cout<<"please enter a celsius value:"<<endl;
	cin>>celsius;
	cout<<celsius<<" degrees celsius is "<<change(celsius)<<" degrees Fahrenheit."<<endl;;

	system("pause");
	return 0;
}
#include <iostream>

using namespace std;

double change(double year){
	return year * 63240;
}

int main(){
	double year;

	cout<<"请输入光年值:";
	cin>>year;
	cout<<"转化成华氏度后:"<<change(year)<<endl;;

	system("pause");
	return 0;
}
#include <iostream>

using namespace std;

void change(int hours,int minutes){
		cout<<"Time:"<<hours<<":"<<minutes<<endl;
}
int main(){
	int hours,minutes;

	cout<<"Enter the number of hours:";
	cin>>hours;
	cout<<"Enter the number of minutes:";
	cin>>minutes;
	
	change(hours,minutes);

	system("pause");
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值