MOOC清华《程序设计基础》第2章第2题:求圆周长2

题目描述

请编写程序计算输出任意半径的圆周长。要求半径从键盘输入,计算时以 3.14159 作为圆周率的值。



输入描述

输入半径为浮点型(float)


输出描述

输出周长,保留小数点后5位。


样例输入

0.5

样例输出
3.14159


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

int main()
{
    float circumference = 0.0, pi = 3.14159, radius = 0.0;
    cin>>radius;
    cout<<fixed<<setprecision(5)<<2 * pi * radius<<endl;
    return 0;
}




posted on 2017-10-05 18:17  sunshineman1986  阅读(129)  评论(0编辑  收藏  举报

导航