码迷,mamicode.com
首页 > 编程语言 > 详细

震惊,C++还有这种骚操作,看看const怎么用

时间:2017-10-22 21:09:46      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:半径   main   c语言   col   name   return   ret   mat   code   

//已知圆柱体的半径和高,求圆柱体的体积。
#include <iostream>
#include <cmath>
using namespace std;

int main()
{   //首次使用const来规定常量;在C语言中会使用#DEFINE
    const float PI = 3.14f;
    float radius = 4.5f;
    float height = 28.7f;
    double volume = PI * pow(radius, 2) * height;
    cout << "the volume is " << volume << endl;
    cin.get();
    return 0;
}

 

震惊,C++还有这种骚操作,看看const怎么用

标签:半径   main   c语言   col   name   return   ret   mat   code   

原文地址:http://www.cnblogs.com/666fengmo666/p/7710807.html

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