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

34 lines
364 B
C++
Raw Permalink Normal View History

2023-07-24 21:05:02 +08:00
#include <iostream>
using namespace std;
namespace Circle
{
float r;
float s();
}
float Circle::s()
{
return 3.14 * r * r;
}
namespace Range
{
int w, h;
int s();
}
int Range::s()
{
return w * h;
}
int main()
{
cout << "输入半径:";
cin >> Circle::r;
float s1 = Circle::s();
cout << "面积: " << s1;
return 0;
}