1.转换说明符

%c 字符

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char a;
    scanf("%c",&a);
    printf("%c\n",a);
    system("pause");
    return 0;
}


%d 有符号十进制整数

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a;
    scanf("%d",&a);
    printf("%d\n",a);
    system("pause");
    return 0;
}


%f 浮点数

#include <stdio.h>
#include <stdlib.h>

int main()
{
    float a;
    scanf("%f",&a);
    printf("%f\n",a);
    system("pause");
    return 0;
}


%o 八进制整数

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a;
    scanf("%d",&a);
    printf("%o\n",a);
    system("pause");
    return 0;
}


%x 十六进制整数

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a;
    scanf("%d",&a);
    printf("%x\n",a);
    system("pause");
    return 0;
}


%s 字符串

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char a[5];
    gets(a);
    printf("%s\n",a);
    system("pause");
    return 0;
}

2.f格式符指定数据宽度和小数位数,用%m.nf。

m指定数据宽度,n指定小数位数
例:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    float a;
    scanf("%f",&a);
    printf("%20.15f\n",a/3);
    system("pause");
    return 0;
}


%20.15f
指定数据宽度为20位,小数位数15位,可以看出,整数部分33前面还有两个空格。算上小数点一共是20个位置。

另:在用%f输出时要注意数据本身能提供的有效数字,如float型数据存储单元只能保证6位有效数字。double型数据能保证15位有效数字。

3.对齐方式

输出的数据向左对齐,用%-m.nf
输出的数据向右对齐,用%m.nf
例:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    float a;
    scanf("%f",&a);
    printf("%-25.15f,%25.15f\n",a/3,a/3);
    system("pause");
    return 0;
}


有负号,输出结果向左靠,右端空5列;无负号,输出结果向右靠,左端空五列。

以上为个人总结,如有问题,请大佬留言指正