#include<iostream>
using namespace std;
int main()
{
cout << "\u65b9\u4f73\u5ffb\u662f\u50bb\u903c\n\n";
cout << "%d 输出十进制,原数是12\n";
int a = 12;
printf("%d\n\n",a); //%d 是输出十进制
cout << "%o 是输出无符号整数的八进制,原数是12\n";
int b = 12;
printf("%o\n\n",b); //%o 是输出无符号整数的八进制
cout << "%x 是输出无符号整数的十六进制,原数是12\n";
int c=12;
printf("%x\n\n",c); //%x 是十六进制
cout << "%5d 输出5个占位字符,右对齐,原数是12\n";
int d=12;
printf("%5d\n\n",d); //%5d 5个占位字符,右对齐
cout << "%-5d 表示5个占位字符,左对齐\n";
int e=12, f=333;
printf("%-5d和%-5d还有%d\n\n",e,f,e); //%-5d 5个占位字符,左对齐
cout << "%+5d +号表示输入符号,前面不是+,正常可以省略+";
int g=-12;
printf("%+5d\n\n",g); //正号表示输入符号,不是前面是+
cout << "%5d 表示占5个字符,左对齐";
int hh=-12;
printf("%5d\n\n",hh); //跟上面一样,默认没有+号可以显示负数
cout << "%02d 表示占位两个字符,首位不够用0补\n";
int hour=13, min=59, sec=1; // %02d 表示占位两个字符,不够加0
printf("%02d:%02d:%02d\n\n",hour,min,sec);
cout << "%f 表示单精度浮点\n";
float aa=1.2;
printf("%f\n\n",aa); //%f 表示单精度浮点
cout << "%e 表示科学计数\n";
float bb=1234567;
printf("%e\n\n",bb); //%e 表示科学计数
cout << "%g 表示不知道变量用什么方式,自动\n";
float cc=1234567,dd=1.2;
printf("cc=%g\n",cc);
printf("dd=%g\n\n",dd); //%g 表示自动判断变量
cout << "%c 输出单个字符, %s 输出字符串\n";
int ee=65;
printf("%d\n",ee); //%d 十进制
printf("%c\n\n",ee); //%c 把ee当作字符串,65的字符串是A
cout << "char 是占位符\n";
char * ff="张三";
printf("我的名字是%s\n\n",ff);
cout << "%p 输出指针指向地址\n";
int a=10;
int *p=&a;
printf("变量a的地址为%p\n",p); //输出“变量a的地址为ox7ffeefbff54c"
}