、头文件
#include <iomanip>
setprecision(), 控制输出流显示浮点数的有效数字个数
和 fixed 合用控制小数点后的位数
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
int main() {
double l,h;
cin >> l >> h;
double w = sqrt(l * l + h * h);
double c = l + h + w;
double d = l * h / 2;
cout << fixed << setprecision(2) << c <<endl;
cout << fixed << setprecision(2) << d << endl;
return 0;
}
前置++ 和 后置++
#include <iostream>
using std::cout;
using std::endl;
int main(){
int i = 1;
cout << i++ << endl;
cout << i << endl;
cout << ++i << endl;
cout << i << endl;
return 0;
}
1 // 后置++ 后做加法
2 // 后置++ 后的值
3 // 前置++, 直接加1
3 // 和前置++ 的 值一样