c語(yǔ)言庫(kù)函數(shù)手冊(cè) 怎樣用c語(yǔ)言把一個(gè)小數(shù)才能化為整數(shù)?
怎樣用c語(yǔ)言把一個(gè)小數(shù)才能化為整數(shù)?1. 方法包括cast、使用庫(kù)函數(shù)round、ceil、floor等。使用示例包括<stdio。H>#包含<math。H>int main(){fl
怎樣用c語(yǔ)言把一個(gè)小數(shù)才能化為整數(shù)?
1. 方法包括cast、使用庫(kù)函數(shù)round、ceil、floor等。使用示例包括<stdio。H>#包含<math。H>int main(){float f=12.5int a=(int)f//cast round int b=round(f)//round int C=ceil(f)//round up int d=floor(f)//round down printf(“a=dNB=dNC=dnd=n”,a,b,C,d)Getchar()返回0}3個(gè)運(yùn)行結(jié)果