code.club

標題: 求浮點數的上下整數 [打印本頁]

作者: enter    時間: 2015-12-11 02:25
標題: 求浮點數的上下整數
#include <iostream>
using namespace std;
       
int main(){
int i=0;       
float f;
cin>>f;

while(i!=f+1)
{
        i++;
        if(i>f) {
                cout<<i-1<<endl;
                break;
        }
}

i = 0;

while(i!=f+1)
{
i++;
if(i>=f)
{
        cout<<i;
        break;
        }       
       
}

        return 0;
       
       
}




歡迎光臨 code.club (http://code.club/) Powered by Discuz! X3.2