#include using namespace std;

float circleArea(float r) { // 定义圆的面积函数 float Pi = 3.14; return Pi * r * r; }

int main() { float r; cout << "请输入圆的半径:"; cin >> r; float area = circleArea(r); // 调用圆的面积函数 cout << "圆的面积为:" << fixed << setprecision(2) << area << endl; // 输出结果,保留两位小数 return 0; }

定义圆的面积函数通过主函数调用面积函数实现圆的面积计算并输出Pi=314输出结果保留两位小数。利用c++

原文地址: http://www.cveoy.top/t/topic/c1FU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录