7472b2f3a5f7c7bdbf425a382b254dd9.png

#include

#include

#define PI 3.14159265358979

void main()

{

double x = 4.0, y = 3.0, e = 1.0, r, h;

int n, i = 0;

while (1)

{

printf("1-Ball\n");

printf("2-Cylinder\n");

printf("3-Cone\n");

printf("other-Exit\n");

printf("Please enter your command:\n");

scanf("%d", &n);

if (n == 1)

{

printf("Please enter the radius:\n");

scanf("%lf", &r);

printf("%.2lf\n", (x / y * 1.0) * PI * pow(r, 3) * 1.0);

}

else if (n == 2)

{

printf("Please enter the radius and the height:\n");

scanf("%lf %lf", &r, &h);

printf("%.2lf\n", h * PI * pow(r, 2) * 1.0);

}

else if (n == 3)

{

printf("Please enter the radius and the height:\n");

scanf("%lf %lf", &r, &h);

printf("%.2lf\n", 1 / y * PI * r * r * h * 1.0);

}

else break;

}

}

原文:https://blog.51cto.com/14737345/2488114

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐