[C++] cout formatting

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
 float x = 123.123556;
 //output:123.124
 cout << fixed <<setprecision(3) << x << endl;
 return 0;
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *