码迷,mamicode.com
首页 > 其他好文 > 详细

int float string按宽度精度输出

时间:2014-08-19 22:10:25      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   2014   div   

 

 

 

 1 #include <stdio.h>
 2 
 3 int main(void)
 4 {
 5     int a = 99;
 6     float b = 9.9;
 7     char c[] = "hello";
 8 
 9     printf("*%010d*\n", a);
10     printf("*%10.3d*\n", a);
11     printf("*%-10.3d*\n", a);
12     printf("*%010.3d*\n", a);
13     printf("*%-010.3d*\n", a);
14     printf("------------\n");
15     printf("*%010f*\n", b);
16     printf("*%10.3f*\n", b);
17     printf("*%-10.3f*\n", b);
18     printf("*%010.3f*\n", b);
19     printf("*%-010.3f*\n", b);
20     printf("------------\n");
21     printf("*%010s*\n", c);
22     printf("*%10.3s*\n", c);
23     printf("*%-10.3s*\n", c);
24     printf("*%010.3s*\n", c);
25     printf("*%-010.3s*\n", c);
26 
27     return 0;
28 }

 

bubuko.com,布布扣

 

如果0标志和精度说明符在字符串和整数输出中同时出现,那么0标志就会被忽略,但浮点数输出仍会显示

int float string按宽度精度输出,布布扣,bubuko.com

int float string按宽度精度输出

标签:style   blog   http   color   io   ar   2014   div   

原文地址:http://www.cnblogs.com/itpoorman/p/3923042.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!