[問題] 想請問這個方程式

看板C_and_CPP (C/C++)作者 (呈呈)時間14年前 (2011/08/30 17:36), 編輯推噓0(0010)
留言10則, 8人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) c++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): /*prog3_4*/ #include <stdio.h> #include <stdlib.h> int main(void) { double f,c; printf("請輸入華氏溫度:"); scanf("%1f",&f); c=(f-32)*(5/9.0); printf("攝氏溫度%.2f=華氏溫度%.2f",c,f); system("pause"); return 0; } 這是我的程式碼 可是執行出來數字都是錯誤的 不知道是哪邊有錯誤 另外關於溫度的方程式 華式=(9/5.0)*攝氏+32; 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) 補充說明(Supplement): -- 小本經營賣場 http://tw.user.bid.yahoo.com/tw/user/Y2286184456 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.33.47.144

08/30 17:46, , 1F
((f-32)*5)/9.0
08/30 17:46, 1F

08/30 18:03, , 2F
為什麼是%1f...
08/30 18:03, 2F

08/30 18:04, , 3F
還是不行耶~ = =
08/30 18:04, 3F

08/30 18:05, , 4F
scanf要讀double應該是用%lf (l是小寫的L)
08/30 18:05, 4F

08/30 18:05, , 5F
scanf後面%lf
08/30 18:05, 5F

08/30 18:11, , 6F
1l1l1l1l 默寫的十次(誤
08/30 18:11, 6F

08/30 19:12, , 7F
把double改成float???
08/30 19:12, 7F

08/30 22:54, , 8F
原來是L XD 話說%lf是甚麼意思阿
08/30 22:54, 8F

08/30 23:27, , 9F
long float
08/30 23:27, 9F

08/30 23:40, , 10F
double float
08/30 23:40, 10F
文章代碼(AID): #1ENAyJBx (C_and_CPP)
文章代碼(AID): #1ENAyJBx (C_and_CPP)