1 三目表达式
if(a<b)
min=a;
else
min=b;
用三木表达式
min=(a<b)?a:b;
满足则a,不满足则b。
2 setw(int n)函数
只对紧接着的输出有效,紧接着的输出结束后又变回默认的域宽。
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
cout << setw(3) << 1 << 1234 << endl;
cout << 1234 << setw(7) << 1234 << 12345 << endl;
cout << 1234 << setw(3) << 12345 << endl;
cout << 1234 << setw(4) << 123456 << 12 << setw(5) << 123 << endl;
return 0;
}