zoukankan      html  css  js  c++  java
  • rwkj 1327 圆柱体体积

    C语言实验一(顺序):题目2、圆柱体体积
    时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte
    总提交:494 测试通过:196

    描述


    请编写一个程序实现以下要求:

    1、输入圆柱体的半径(radius)和高(high);

    2、定义PI为3.14159;

    3、求出圆柱体的体积。


    输入


    输入两个实数,第一个是圆柱体的半径,第二个是圆柱体的高。


    输出


    输出有三行:

    第一行是圆柱体的半径;

    第二行是圆柱体的高;

    第三行圆柱体的体积。

    每一个输出的结果保留到小数点后3位。


    样例输入

    3.8 5
    3 4

    样例输出

    radius:3.800
    high:5.000
    The volume is:226.823
    radius:3.000
    high:4.000
    The volume is:113.097

    提示


    使用double类型


    #include <stdio.h>
    int main()
    { double r,h;
    while (scanf("%lf%lf",&r,&h)==2)
    {
    printf("radius:%.3f ",r);
    printf("high:%.3f ",h);
    printf("The volume is:%.3f ",3.14159*r*r*h);
    }
    }


    #include <stdio.h>

    int main()
    { double r,h,v;
    while ( scanf("%lf%lf",&r,&h) !=EOF )
    { v=3.14159*r*r*h;
    printf("radius:%.3lf ",r);
    printf("high:%.3lf ",h);
    printf("The volume is:%.3lf ",v);
    }

    }

    #include<iostream>
    #define PI 3.14159
    #include<iomanip>
    using namespace std;
    int main()
    {
    double radius,high;
    while(cin>>radius>>high)
    {
    cout<<fixed<<setprecision(3)<<"radius:"<<radius<<endl<<"high:"<<high<<endl<<"The volume is:"<<PI*radius*radius*high<<endl;
    }return 0;
    }

    #include <iostream>
    #include <iomanip>
    using namespace std;

    int main()
    { double r,h,v;
    while (cin>>r>>h)
    { cout<<fixed<<setprecision(3)<<"radius:"<<r<<endl;
    cout<<fixed<<setprecision(3)<<"high:"<<r<<endl;
    cout<<fixed<<setprecision(3)<<"The volume is:"
    <<3.14159*r*r*h<<endl;
    }

    return 0;
    }

  • 相关阅读:
    PostgerSQL 回收表空间,查看占用磁盘大小
    为 Docker 添加阿里云的镜像地址
    Docker 常用命令
    CentOS 7 安装 Docker
    kafka-常用脚本2
    Nginx 端口被占用(0.0.0.0:443 failed (98: Address already in use))
    nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)
    检查Nginx 配置文件出否有问题
    Python2 安装虚拟环境
    记录 | 程序员技术博客平台推荐和选取
  • 原文地址:https://www.cnblogs.com/2014acm/p/3911212.html
Copyright © 2011-2022 走看看