#include <iostream>
#include <cmath>
using namespace std;
int round(double number);
int main() {
double num;
char ans;
do {
cout << "Enter a double value: ";
cin >> num;
cout << "Rounded that number is " << round(num) << endl;
cout << "Again?(y/n):";
cin >> ans;
}while(ans == 'y' || ans == 'Y');
cout << "End of test.\n";
return 0;
}
int round(double number) {
return static_cast<int>(floor(number + 0.5));
}
非負數四捨五入
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.