Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to change C language from floating-point number to shaping
How to change C language from floating-point number to shaping
One method is not to output the decimal part after F.

printf("%.0f ",s)

%f outputs 6 decimal places by default, and the way to customize decimal places is% x.yf

X is the number of digits in the integer part. If it is insufficient, put a space before it. Y is the number of digits in the decimal part. xy is a positive integer, separated by dots.

There is also a cast to int type.

printf("%d ",(int)s);