有同學在問, 為什麼輸入浮點數 (e.g. 6.0), cout 出來卻變整數 (6)
這是關於 cout 出來 precision 的問題.
By default, cout 的 precision 是六位數, 而且會將小數點最後面的 0 省略掉.
If you really want to see the 小數點, you can do:
cout << showpoint << n << endl;
where showpoint is an iostream manipulator. We will talk about some of them
in lecture note 3.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.121.131.190