#include <stdio.h>
#include <math.h>
#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;
}
}
PTA ----- 圆形体体积计算器
原创GreyPigeon 博主文章分类:PTA ©著作权
©著作权归作者所有:来自51CTO博客作者GreyPigeon的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:PTA ---- 特立独行的幸福
下一篇:PTA ----- 藏尾诗
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Java 求球的体积
题目描述编写程序,先输出一个提示信息“请输入圆球的半径:”,等用户在提示信息的冒号后输入半径后
提示信息 格式输出 java -
12:计算球的体积
原题链接总时间限制: 1000ms 内存限制: 65536kB描述对于半径为r的球,其体积的计算公式为V=4/3*πr3,这里取π= 3.14。现给
java 数据结构 算法 python c语言 -
算法提高 7-1用宏求球的体积
问题描述 使用宏实现计算球体体积的功能。用户输入半径,系统输出体积。不能
#include 数据 ios -
HDU - 2002 计算球的体积
题目根据输入的半径值,计算球的体积。 Input 输入数据有多组,每组占一行,每行包括一个实数
HDU 体积 java 编程 ACM