前面补零:
printf("%3d",a); //如果知道位数具体数字 printf("%*d",n,a);//不知道具体数字,用*代替位数,n为保留的位数
后面补零
printf("%-3d",a); printf("%-*d",n,a); //加负号即可