6_53.cpp

来自「C++程序设计技能百练随书配套光盘的源码」· C++ 代码 · 共 44 行

CPP
44
字号
 #include<iostream.h>
const double pi=3.1415926;
struct Column
{
	double radius;
	double height;
}myc;

void SetColumn()
{
	double r,h;
	cout<<"Input the radius and height of a column!";
	cout<<endl;
	cout<<"radius=";
	cin>>r;
	cout<<"height=";
	cin>>h;
	myc.radius=r;
	myc.height=h;
}
double getvolume()
{
	return pi*myc.radius*myc.radius*myc.height;
}
double getsurface()
{
	return 2*pi*myc.radius*(myc.height+myc.radius);
}
void disp()
{
	cout<<"The volume of the column is "<<getvolume();
	cout<<endl;
	cout<<"The surface of the column is "<<getsurface();
	cout<<endl;
}

void main()
{
	SetColumn();
	getvolume();
	getsurface();
	disp();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?