描述
Given radius r
, returns the circle's circumference nums[0]
and area nums[1]
.The result retains two decimal places.
PI = 3.14
您在真实的面试中是否遇到过这个题?
是
样例
Given r
= 2
return [12.56, 12.56]
没什么难度的题:
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
vector<double> result;
result.push_back(2*r*3.14);
result.push_back(3.14*pow(r,2));
return result;
}
};