如何像这样打印 See This
答案 0 :(得分:1)
#include <stdio.h>
typedef enum
{
O_VER,
O_HOR,
/* you can add your own */
}ORDER_t;
void printInCols(int startnum, int nCols, int nRows, ORDER_t order)
{
for(int row = 0; row < nRows; row++)
{
for(int col = 0; col < nCols; col++)
{
switch(order)
{
case O_VER:
printf("%6d\t", startnum + row + col * (nCols + 1));
break;
case O_HOR:
printf("%6d\t", startnum + col + row * (nCols));
break;
}
}
printf("\n");
}
}
int main()
{
printInCols(4,6,7,O_HOR);
printf("\n\n");
printInCols(4,6,7,O_VER);
}
答案 1 :(得分:1)
#include <stdio.h>
int main(void) {
for(int i=1; i<=10; i++) printf("%i\t%i\r\n", i, i+10);
return 0;
}
输出:
1 11
2 12
3 13
4 14
5 15
6 16
7 17
8 18
9 19
10 20