C语言printf左对齐和右对齐
C语⾔printf左对齐和右对齐C 语⾔ printf("%d", n) 默认是左对齐,⽽如果是给定了数字宽度,如:printf("%5d", n);这个默认是右对齐,⽽要改成左对齐,只需要加⼀个负号即可:printf("%-5d", n);⽰例:#include <stdio.h>#include <string.h>#define maxn 20int a[maxn][...
2023-12-02 21 0
C语⾔printf左对齐和右对齐C 语⾔ printf("%d", n) 默认是左对齐,⽽如果是给定了数字宽度,如:printf("%5d", n);这个默认是右对齐,⽽要改成左对齐,只需要加⼀个负号即可:printf("%-5d", n);⽰例:#include <stdio.h>#include <string.h>#define maxn 20int a[maxn][...