提示:圆周率pi参照p16例题2-5用符号常量PI定义为3.1415926
圆柱体体积计算公式:v=PI*r*r*h
圆柱体表面积计算公式:s=2*PI*r*r+2*PI*r*h
谁知道的麻烦告诉下,谢谢啦!
#include<iostream.h>
#include<stdio.h>
#define PI 3.1415926
int main()
{
double r,h;
double v,s;
cout<<"请输入:"<<endl;
cin>>r>>h;
v = PI * r * r * h;
s = 2 * PI * r * r + 2 * PI * r * h;
cout<<"v="<<v<<endl;
cout<<"s="<<s<<endl;
return 0;
}
#include<stdio.h>
#define PI 3.1415926
int main()
{
double r,h;
double v,s;
cout<<"请输入:"<<endl;
cin>>r>>h;
v = PI * r * r * h;
s = 2 * PI * r * r + 2 * PI * r * h;
cout<<"v="<<v<<endl;
cout<<"s="<<s<<endl;
return 0;
}
温馨提示:答案为网友推荐,仅供参考