当前位置:首页 » 编程语言 » C语言上升法

C语言上升法

发布时间: 2024-09-18 02:42:31

❶ 关于C语言的除法与取整问题!

函数名: ceil
功 能: 向上舍入
用 法: double ceil(double x);
函数名: floor
功 能: 向下舍入
用 法: double floor(double x);

另外 (int)(表达式) ,将 [表达式]结果向下取整

下面举一例:
#include<stdio.h>
#include<math.h>
int main(void){
int x=11;
int y=0,z=0;
double a=12.69,b=0.0,c=0.0;
y = x/3 ;
z = (int)a;
b = floor(a);
c = ceil(a);
printf("\n \t y = %d \n",y); // y = 3
printf("\n \t z = %d \n",z); // z = 12
printf("\n \t b = %5.2lf",b); // b = 13.00
printf("\n \t c = %5.2lf",c); // c = 12.00
return 0;
}

热点内容
编程用什么轴机械键盘 发布:2025-05-17 18:10:35 浏览:958
金融工程编程 发布:2025-05-17 18:10:33 浏览:222
私密模式访问 发布:2025-05-17 18:09:44 浏览:787
数据库崩溃原因 发布:2025-05-17 18:09:42 浏览:306
对虾养殖增氧机如何配置 发布:2025-05-17 18:08:20 浏览:442
linux读写权限 发布:2025-05-17 18:08:12 浏览:314
导出蜂窝脚本 发布:2025-05-17 18:03:25 浏览:564
中国银行定期存储的利率 发布:2025-05-17 18:00:03 浏览:989
数据库小于 发布:2025-05-17 17:59:02 浏览:409
凝思加密文件 发布:2025-05-17 17:59:02 浏览:402