|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<math.h>
#define p 3.14
int main()
{
double r,gao,zhouchang,mianji,yuanqiubiaomianji,yuanqiutiji,yuanzhutiji;
printf("请输入半径和高:");
scanf("%f,%f",&r,&gao);//r=1.5,gao=3
zhouchang=2*p*r;
mianji=p*pow(r,2);
yuanqiubiaomianji=4*p*pow(r,2);
yuanqiutiji=(4/3)*p*pow(r,3);
yuanzhutiji=p*pow(r,2)*gao;
printf("圆周长是%.2f\n圆面积是%.2f\n圆球表面积是%.2f\n圆球体积是%.2f\n圆柱体积是%.2f\n",
zhouchang,mianji,yuanqiubiaomianji,yuanqiutiji,yuanzhutiji);
return 0;
}
弹出命令框后,输入 1.5,3 运算结果不正确
%lf
宏定义请用大写
#include<stdio.h>
#include<math.h>
#define PI 3.14
int main()
{
double r,gao,zhouchang,mianji,yuanqiubiaomianji,yuanqiutiji,yuanzhutiji;
printf("请输入半径和高:");
scanf("%lf,%lf",&r,&gao);//r=1.5,gao=3
zhouchang=2*PI*r;
mianji=PI*pow(r,2);
yuanqiubiaomianji=4*PI*pow(r,2);
yuanqiutiji=(4/3)*PI*pow(r,3);
yuanzhutiji=PI*pow(r,2)*gao;
printf("圆周长是:%.2lf\n圆面积是:%.2lf\n圆球表面积是:%.2lf\n圆球体积是:%.2lf\n圆柱体积是:%.2lf\n",
zhouchang,mianji,yuanqiubiaomianji,yuanqiutiji,yuanzhutiji);
return 0;
}
|
|