- %d 整型格式控制符
- %f 浮点型(单精度)格式控制符
- %i 整型格式控制符,和%d完全一样
- %u 无符号整型格式控制符
- %c 字符格式控制符
- %s 字符串格式控制符
- %lf 双精度格式控制符
- %e 指数形式输出格式控制符
- %o 无符号八进制数格式控制符
- %x 无符号十六进制格式控制符,如:1f
- %X 无符号十六进制格式控制符,如:1F
- %g 自动选f格式或e格式中较短的一种,不输出无意义的零
说明:
1,%-5.2f 表示输出数据长度为5的数,且保留2位小数,向左对齐
2,%5.2f 表示输出数据长度为5的数,且保留2位小数,向右对齐
3,- 表示数向左对齐。+ 表示数向右对齐。一般 + 省略不写
4,%m.nf 中m表示整个数据的整体长度(包括小数点),n表示小数点后面的数的长度