標籤
- C
- android
- Objective-c
- Sort
- BlueTooth
- Python
- 133
- Apache
- ArrayList
- BluetoothChat
- C sharp
- C#
- CVS
- CheckBox
- Closest Pair
- Console.ReadLine
- HashMap
- NFC
- NSDocumentDirectory
- NSString
- Pandaboard
- SQLite
- UIAlertController
- VB
- Xcode6
- driver
- execSQL
- gatt error
- httpd.conf
- office
- primie check
- property
- sharedApplication
- 小小問題
2015年9月23日 星期三
Two floating numbers 四捨五入
Input two floating numbers X and P.
a. 0 < X <1
b. P = 1 / 0.1 / 0.01/ 0.001
c. answer format %.4f
ex:
if X is 0.5678 and P is 0.01, then the answer is 0.5700
if X is 0.1269 and P is 0.1, then the answer is 0.1000
#include <stdio.h>
int main(void) {
float x, p;
while(EOF != scanf("%f %f", &x, &p)) {
if (0 < x && x < 1) {
x = (int)(x*(1/p) + 0.5);
printf("%0.4f\n", x/(1/p));
}
}
return 0;
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言