當前位置:首頁 » 編程語言 » 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;
}

熱點內容
我配置很高了ae為什麼卡 發布:2025-05-17 14:54:50 瀏覽:167
python數據分析實戰pdf 發布:2025-05-17 14:49:42 瀏覽:950
海瀾之家廣告腳本 發布:2025-05-17 13:56:06 瀏覽:30
手文件夾恢復 發布:2025-05-17 13:53:32 瀏覽:993
linux怎麼看進程 發布:2025-05-17 13:53:30 瀏覽:303
thinkphp欄位緩存 發布:2025-05-17 13:52:01 瀏覽:575
山靈app安卓版如何設置 發布:2025-05-17 13:51:49 瀏覽:388
帆布壓縮袋 發布:2025-05-17 13:26:27 瀏覽:457
c語言16進製表示方法 發布:2025-05-17 13:11:25 瀏覽:480
ftp單位 發布:2025-05-17 13:10:03 瀏覽:142