[問題] 浮點數運算問題
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
dev c++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
iostream,cstdlib
問題(Question):
出來的資料是科學記號看不懂
餵入的資料(Input):
20
預期的正確結果(Expected Output):
20*33.23=664.6
錯誤結果(Wrong Output):
2.50222e-036
程式碼(Code):(請善用置底文網頁, 記得排版)
http://ideone.com/rfblT
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
float USD;
float NTD;
float EX=33.23f;
int n;
cout << "目前匯率 1USD=33.23*NTD" << endl;
cout << "請輸入你要換算的美元數:";
cin >> n;
cout << "這是你輸入的美元數:" << n << endl;
USD=n*NTD*EX;
cout << "這是換算出來的台幣數:" << float(USD) << endl;
system("pause");
return 0;
}
補充說明(Supplement):
請建議哪裡的想法錯誤,要重看洪維恩 c++ ver.3 哪裡,謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.204.159.106
→
04/30 15:39, , 1F
04/30 15:39, 1F
→
04/30 15:40, , 2F
04/30 15:40, 2F
→
04/30 16:39, , 3F
04/30 16:39, 3F
→
04/30 16:40, , 4F
04/30 16:40, 4F
→
04/30 16:40, , 5F
04/30 16:40, 5F
→
04/30 16:48, , 6F
04/30 16:48, 6F
→
04/30 17:51, , 7F
04/30 17:51, 7F
→
04/30 17:51, , 8F
04/30 17:51, 8F
→
04/30 18:40, , 9F
04/30 18:40, 9F
→
04/30 18:41, , 10F
04/30 18:41, 10F
→
04/30 18:43, , 11F
04/30 18:43, 11F
→
04/30 18:46, , 12F
04/30 18:46, 12F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章