码迷,mamicode.com
首页 > 其他好文 > 详细

PTA ----- 圆形体体积计算器

时间:2020-04-17 18:32:07      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:ase   include   other   inf   can   pow   clu   amp   lease   

技术图片

#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 ----- 圆形体体积计算器

标签:ase   include   other   inf   can   pow   clu   amp   lease   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!