當前位置:首頁 » 編程語言 » 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-03 03:06:00 瀏覽:520
腳本家的台詞 發布:2025-07-03 03:05:50 瀏覽:708
arcgisforpython 發布:2025-07-03 03:05:46 瀏覽:898
期計演算法 發布:2025-07-03 02:56:53 瀏覽:404
不同域訪問 發布:2025-07-03 02:49:05 瀏覽:818
多槽編程 發布:2025-07-03 02:47:42 瀏覽:919
sql2008錯誤233 發布:2025-07-03 02:28:52 瀏覽:168
創建資料庫語句mysql 發布:2025-07-03 02:14:34 瀏覽:146
python量化投資 發布:2025-07-03 02:05:11 瀏覽:804
proxy代理伺服器地址 發布:2025-07-03 01:56:52 瀏覽:910