//printf的使用和int、float、double格式的控制
//%:表示格式说明的起始符号,不可缺少 %i,%f等等就理解成一个占位置的坑,除了这个坑其他位置都随意填写
#include <stdio.h>
int main(int argc, const char * argv[]) {
//1、输出整型、单精度、双精度、字符类型数据
int intValue=0;
float floatValue=1.1;
double doubleValue=1.1;
char charValue='c';
printf("%i\n",intValue);
printf("%f\n",floatValue);
printf("%lf\n",doubleValue);
printf("%c\n",charValue);
//2、指定位宽输出 %m
int intValue2=99;
printf("%5i!!!\n",intValue2);//默认情况下右对齐
printf("%-5i!!!\n",intValue2);//左对齐
// 注意: 如果指定了位宽, 但是实际输出的内容超出了宽度, 会按照实际的宽度来输出
int intValue3 = 9999;
printf("%2i\n", intValue3);
int intValue4=9;
printf("%05i\n",intValue4);
//3、保留位数 %.n
float floatValue2=1.1;
double doubleValue2=2.22;
printf("%.3f!!!\n",floatValue2);
printf("%.10lf\n",doubleValue2);
//4、指定位宽和保留位数的综合 %m.n
float floatValue3=12.1234;
printf("%06.2f\n",floatValue3);//位宽是总的宽度
//5、float有效位为7(不包含小数点),double有效为15(不含小数点)
//默认float都是显示6位小数
float floatValue4=3.141592653;
printf("%f\n",floatValue4);
printf("%.10f\n",floatValue4);
double doubleValue3=3.141592653545;
printf("%f\n",doubleValue3);
printf("%.15lf\n",doubleValue3);
//6、提高逼格
printf("%.*f\n",4,floatValue4);
return 0;
}