复习题练习答案分享
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int a = 12, b = 8, c = 6;
// Q1
int ans1 = pow(a, 2) + pow(b, 2) + pow(c, 2);
// Q2
double ans2 = pow(a / 2.0, 2) + pow(b / 2.0, 2) + pow(c / 2.0, 2);
// Q3
double ans3 = sqrt(ans1);
// Q4
double ans4 = pow(sqrt(5) + 1, 2) / 2 - 1;
cout << "Q1的答案是:" << ans1 << endl;
cout << "Q2的答案是:" << ans2 << endl;
cout << "Q3的答案是:" << ans3 << endl;
cout << "Q4的答案是:" << ans4 << endl;
return 0;
}
cmath>iostream>
下载地址
用户评论