[問題] C++作業一問

看板C_and_CPP作者 (樂觀&神秘)時間15年前 (2010/06/12 20:10), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/2 (看更多)
想請問 題目要我做什麼 我努力的查字典 可是還是擔心我翻譯的是錯誤的 >> Function floor can be used to round a number to a specific decimal place. The statement y = floor( x * 10 + .5 ) / 10; rounds x to the tenths position (the first position to the right of the decimal point). The statement y = floor( x * 100 + .5 ) / 100; rounds x to the hundredths position (the second position to the right of the decimal point). Write a program that defines four functions to round a number x in various ways: roundToInteger( number ) roundToTenths( number ) roundToHundredths( number ) roundToThousandths( number ) For each value read, your program should print the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth and the number rounded to the nearest thousandth. 首先 floor 指令 的意思 我大概知道 就是回傳一個最大的整數 但不大於本身 題目的意思 是要我 建立四個function 分別是做什麼呢? 希望大大幫我 感謝 只要告訴我究竟在問什麼><" 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.169.141.205

06/12 20:20, , 1F
整數,小數點以下1, 2, 3位的四捨五入,運用floor ()
06/12 20:20, 1F
文章代碼(AID): #1C4tat3c (C_and_CPP)
文章代碼(AID): #1C4tat3c (C_and_CPP)