用C ++查找半圆的面积和周长的程序
为此,我们将获得一个圆的半径。我们的任务是找到给定半径的半圆的面积和周长。
示例
#include <iostream>
using namespace std;
//计算半圆的面积
float area(float r) {
return (0.5)*(3.14)*(r * r);
}
//计算周长
float perimeter(float r) {
return (3.14)*(r);
}
int main() {
int r = 10;
cout << "The Area of Semicircle: "<< area(r) << endl;
cout << "The Perimeter of Semicircle: "<< perimeter(r) << endl;
return 0;
}输出结果
The Area of Semicircle: 157 The Perimeter of Semicircle: 31.4
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短