题目要求:LintCode
先把基本的写出来,为了看起来有个大概有个样子(1)每行换行;(2)输出结果5个空格,左对齐(%-5d):
关于%-nd的知识:+是右对齐,-是左对齐;数值n代表几个空格,如果是左对齐,就把串数字靠左,否则,靠右。
#include <stdio.h>
int main() {
// Write your code here
for(int i = 1; i < 10; i++){
printf("\n");
for(int j = 1; j < 10; j++){
printf("%d * %d = %-5d",i,j,i*j);
}
}
return 0;
}
然后对半切分(j <= i):
before:
for