向上向下取整函数

 1 #include<iostream>
 2 #include<cmath>
 3 using namespace std;
 4 //ceil()向上取整
 5 //floor()向下取整 
 6 int main(){
 7     int a,b;
 8     cin>>a>>b;
 9     cout<<"向上取整"<<ceil((double)a/b)<<endl;
10     cout<<"向下取整"<<floor((double)a/b);
11     return 0; 
12 }

运行结果:

猜你喜欢

转载自www.cnblogs.com/1129-tangqiyuan/p/11110256.html