//============================================================================
// 제출일 : 2005. 3. 12
// 작업환경 : Windows XP SP1, VC++ 6.0, Pentium4
// 연습문제 4-35
//============================================================================
#include <iostream.h>
#include <math.h>
float round(float num);
int main()
{
float num;
cout << "아무수나 입력하세요\n";
cin >> num;
cout << "Ceiling : " << ceil(num) << "\n";
cout << "Floor : " << floor(num) << "\n";
cout << "Round : " << round(num) << "\n";
return 0;
}
float round(float num)
{
float temp;
temp = (int)num;
temp = num - temp;
if (num > 0)
{
if (temp >= 0.5)
return ceil(num);
else
return floor(num);
}
else
{
if (temp >= -0.5)
return ceil(num);
else
return floor(num);
}
}
'Studies > A Structured Approach Using C++' 카테고리의 다른 글
Project 4-39 Temperature convertor : Fathrenheit VS Centigrade 온도변환기 : 화씨 섭씨 (0) | 2008.08.23 |
---|---|
Project 4-38 Compute the interest and print the balance (0) | 2008.08.23 |
Project 4-37 Prepare a payroll earnings statement (0) | 2008.08.23 |
Problem 4-33 Modify the "Add two digit" grogram (0) | 2008.08.23 |
Computer Science: A structured approach using C++ (0) | 2008.08.21 |