计算圆周长和面积

给定半径r,返回圆的周长nums[0]和面积nums[1].结果保留了两位小数.

样例

样例 1:

输入 : r = 2
输出 : [12.56, 12.56]

注意事项

PI = 3.14

 

class Solution {
public:
    /**
     * @param r: a Integer represent radius
     * @return: the circle's circumference nums[0] and area nums[1]
     */
    vector<double> calculate(int r) {
        // write your code here
        double zhouchang = 2*3.14*r;
        double mianji = 3.14*r*r;
        vector<double> ret;
        ret.push_back(zhouchang);
        ret.push_back(mianji);
        return ret;
    }
};

 

    原文作者:俺 也一样
    原文地址: https://blog.csdn.net/weixin_41791402/article/details/99284055
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞