输入圆的半径,输出圆的周长和面积

时间:2025-04-03 07:14:18
#include < iostream>
#include < cmath>
using namespace std;
const double PI = 3.14159; //定义一个常量PI #define PI 3.14159
int main()
{
int r;
double p, a;
cout << "请输入半径: ";
cin >> r;
p = 2 * PI * r;
a = PI * pow(r, 2);
cout << "周长是 : " << p << endl;
cout << "面积是 : " << a << endl;
return 0;
}

相关文章