例
#include <bits/stdc++.h> using namespace std; //寻找区域 float findArea(float a) { float area; area = 5 * sqrt(3) * a * a; return area; } //查找量 float findVolume(float a) { float volume; volume = ((float)5 / 12) * (3 + sqrt(5)) * a * a * a; return volume; } int main() { float a = 5; cout << "Area: " << findArea(a) << endl; cout << "Volume: " << findVolume(a); return 0; }
输出结果
Area: 216.506 Volume: 272.712