atb*_*atb 10 c floating-point string-formatting format-specifiers
有没有办法让用户输入浮点格式说明符?例如,如果我打印这个.
float c = 15.0123
printf("%.2f", c);
// outputs: 15.01
Run Code Online (Sandbox Code Playgroud)
如何为变量分配小数位数?喜欢:
int n = 3;
float c = 15.0123
printf("%.(%i)f", n, c);
// outputs: 15.012
Run Code Online (Sandbox Code Playgroud)
oua*_*uah 20
精度可以用带星号的参数指定*.这称为参数提供的精度.
float c = 15.0123;
int m = 2;
printf("%.*f", m, c);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3370 次 |
| 最近记录: |