qfedu-cpp-level/day1/homework/h5.cpp

24 lines
536 B
C++

#include <iostream>
#include <cmath>
using namespace std;
const float PI = 3.14159;
double Area(double a, double b)
{
return PI * pow(a, 2) * b / 360;
}
double Area(double a)
{
return PI * pow(a, 2);
}
int main(int argc, char const *argv[])
{
double r, x;
cout << "请输入半径和角度: " << endl;
cin >> r >> x;
cout << "半径为 " << r << ", 角度为 " << x << " 的扇形面积为: " << Area(r, x) << endl;
cout << "半径为 " << r << ", 的圆的面积为: " << Area(r) << endl;
return 0;
}