printf输出对齐问题

来源:百度知道 编辑:UC知道 时间:2024/07/04 15:00:47
printf("The smallest number is: %d. rol: %d, col: %d\n",fs[tr1][tc1],tr1,tc1);
printf("The smaller number is: %d. rol: %d, col: %d\n",fs[tr2][tc2],tr2,tc2);
printf("The third small number is: %d. rol: %d, col: %d\n",fs[tr3][tc3],tr3,tc3);
printf("The forth small number is: %d. rol: %d, col: %d\n",fs[tr4][tc4],tr4,tc4);

不如这样的输出
我想让输出结果像表格一样各个部分是对齐的
该怎么改?
cgiggle,我知道这个写法,但你这样前面的英语句子本身就不齐了,这样后面即使用%4d规定一下也没有用啊!!?- -?

to:西西泸
直接加空格?囧/.\ 这是4句,如果是400句、4000句……呢?累死哇/口\

这样试试
printf("The ....\t%d\n",i);
在英语后面加一个跳格符

要么 这样
printf("The smallest number is: %d. rol: %d, col: %d\n",fs[tr1][tc1],tr1,tc1);
printf("The smaller number is: %d. rol: %d, col: %d\n",fs[tr2][tc2],tr2,tc2);
printf("The third small number is: %d. rol: %d, col: %d\n",fs[tr3][tc3],tr3,tc3);
printf("The forth small number is: %d. rol: %d, col: %d\n",fs[tr4][tc4],tr4,tc4);
齐了吧!! 直接加空格就是了。。

我前面有啊!!! 加个\t 如果 你自己看着办 如果2个 printf间的英文字母相差在一个\t内就加一个\t 多的补空格。。。。
一个\t是8列 不多吧!!!

printf("The ....\t%d\n",i);
在英语后面加一个跳格符

printf("The smallest number is: %d. rol: %d, col: %d\n",fs[tr1][tc1],tr1,tc1);
printf("The smaller number is: %d. rol: %d, col: %d\n",fs[tr2][tc2],tr2,tc2);
printf("The third small number is: %d. rol: %d, c