adinxu
by adinxu
1 分钟 阅读用时

分类

标签

编程常用资料收集

文章目录

ascii码表

c语言取整与四舍五入

floor函数
向下取整。floor(x)返回的是x的整数部分。如: floor(2.5) = 2 floor(-2.5) = -3

ceil函数
向上取整。ceil(x)返回的是不大于x的最小整数。如: ceil(2.5) = 3 ceil(-2.5) = -2 floor和ceil对于正数没有区别,但是对于负数结果不同。floor()是向负无穷大舍入,floor(-2.5) = -3;ceil()是向正无穷大舍入,ceil(-2.5) = -2。

round(x) 返回x的四舍五入整数值。

printf格式符

length d i u o x X f F e E g G a A c s p n
(none) int unsigned int double int char* void* int*
hh signed char unsigned char signed char*        
h short int unsigned short int short int*        
l long int unsigned long int wint_t wchar_t* long int*    
ll long long int unsigned long long int long long int*        
j intmax_t uintmax_t intmax_t*        
z size_t size_t size_t*        
t ptrdiff_t ptrdiff_t ptrdiff_t*        
L long double            

注:此表格说明了各种控制符及其长度符号的各种组合及适用对象,比如%ld用于long int符号,而

printf格式符释义

specifier Output Example
d or i Signed decimal integer 392
u Unsigned decimal integer 7235
o Unsigned octal 610
x Unsigned hexadecimal integer 7fa
X Unsigned hexadecimal integer (uppercase) 7FA
f Decimal floating point, lowercase 392.65
F Decimal floating point, uppercase 392.65
e Scientific notation (mantissa/exponent), lowercase 3.9265e+2
E Scientific notation (mantissa/exponent), uppercase 3.9265E+2
g Use the shortest representation: %e or %f 392.65
G Use the shortest representation: %E or %F 392.65
a Hexadecimal floating point, lowercase -0xc.90fep-2
A Hexadecimal floating point, uppercase -0XC.90FEP-2
c Character a
s String of characters sample
p Pointer address b8000000
n Nothing printed. The corresponding argument must be a pointer to a signed int.The number of characters written so far is stored in the pointed location.  
% A % followed by another % character will write a single % to the stream. %