當前位置:首頁 » 編程語言 » 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-07-11 07:43:33 瀏覽:387
邁騰有什麼安全配置 發布:2025-07-11 07:42:40 瀏覽:644
c語言字元逆序 發布:2025-07-11 07:41:57 瀏覽:923
怎麼配置交換機的console密碼 發布:2025-07-11 07:41:57 瀏覽:4
東芝存儲卡視頻 發布:2025-07-11 07:41:55 瀏覽:541
cs16為什麼搜不到區域網伺服器 發布:2025-07-11 07:41:21 瀏覽:913
php項目如何上傳伺服器 發布:2025-07-11 07:35:35 瀏覽:182
壓縮機4井 發布:2025-07-11 07:34:57 瀏覽:726
win7訪問共享 發布:2025-07-11 07:34:48 瀏覽:279
telnetlinux退出 發布:2025-07-11 07:29:46 瀏覽:791