6_53.cpp
上传用户:zipjojo
上传日期:2009-07-20
资源大小:70k
文件大小:1k
- #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();
- }