函數(shù)名:modf

創(chuàng)新互聯(lián)主營甕安網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都App定制開發(fā),甕安h5小程序制作搭建,甕安網(wǎng)站營銷推廣歡迎甕安等地區(qū)企業(yè)咨詢
頭文件:math.h
函數(shù)原型:double
modf(double
x,
double
*ipart)
函數(shù)用途:分解x,以得到x的整數(shù)和小數(shù)部分
輸入?yún)?shù):x
待分解的數(shù)
輸出參數(shù):ipath
x
的整數(shù)部分
返回值:x
的小數(shù)部分
實例:
#include
math.h
#include
stdio.h
int
main(void)
{
double
fraction,
integer;
double
number
=
100000.567;
fraction
=
modf(number,
integer);
printf("The
whole
and
fractional
parts
of
%lf
are
%lf
and
%lf
",number,
integer,
fraction);
return
可以參考下面的代碼:
#includestdio.h
int?main()
{
char?c;
int?num=0,lett=0,bar=0,others=0;
scanf("%c",c);
while(c!='#')
{
if(c=='?')?bar++;
else?if(c='0'c='9')?num++;
else?if(c='a'c='z'?||?c='A'c='Z')?lett++;
else?others++;
scanf("%c",c);
}
return?0;
}
擴(kuò)展資料:
C語言函數(shù):
C語言labs()函數(shù):求整數(shù)的絕對值(針對long類型)
C語言isgraph()函數(shù):判斷一個字符是否是圖形字符
C語言frexp()函數(shù):提取浮點數(shù)的尾數(shù)和指數(shù)部分
C語言modf()函數(shù):提取浮點數(shù)的小數(shù)和整數(shù)部分
C語言isspace()函數(shù):判斷一個字符是否是空白符
C語言strcpy()函數(shù):字符串復(fù)制(拷貝)函數(shù)
參考資料來源:百度百科-c語言
mod的原理就是求余數(shù)。
比如:10除以3,商是3,余數(shù)是1
在c++里面,用'/'表示求商,而用%表示秋余數(shù)
所以10/3=3,10%3=1。
擴(kuò)展資料:
語法:
MOD(number,divisor)
參數(shù):
Number 為被除數(shù)。
Divisor 為除數(shù)。
在Oracle中,如果 divisor 為0,則函數(shù)直接返回number。
說明:
函數(shù)MOD可以借用函數(shù) INT 來表示:
MOD(n, d) = n - d*INT(n/d)
示例:
MOD(3, 2) 等于 1
MOD(-3, 2) 等于1
MOD(3, -2) 等于-1
MOD(-3, -2) 等于-1
MOD(-3, 0) 等于-3
MOD(3, 0) 等于3
MOD(2, 0) 等于2
MOD(4, 3) 等于1
而在Excel中,除數(shù)不能為0,否則會報錯。
MOD(3, -2) 等于-1(與后面的數(shù)符號相同)
MOD(3, 0) 報錯,輸出結(jié)果為#DIV/0!
參考資料:
百度百科-MOD函數(shù)
modf 函數(shù)名: modf
功 能: 把數(shù)分為整數(shù)和小數(shù) (The modf function breaks down the floating-point value x into fractional and integer parts, each of which has the same sign as x. The signed fractional portion of x is returned. The integer portion is stored as a floating-point value at intptr.
)
用 法: double modf(double x, double *intptr);
程序例:
#include math.h
#include stdio.h
int main(void)
{
double fraction, integer;
double number = 100000.567;
fraction = modf(number, integer);
printf("The whole and fractional parts of %lf are %lf and %lf\n",
number, integer, fraction);
return 0;
}
新聞標(biāo)題:c語言自定義modf函數(shù) c++ mod函數(shù)
網(wǎng)站路徑:http://chinadenli.net/article12/hhjogc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計、品牌網(wǎng)站制作、企業(yè)建站、網(wǎng)站維護(hù)、網(wǎng)站設(shè)計公司、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)