用c语言输出九九乘法表要求输出三列,输出格式为輸出格式 : 1X1 = 1 2X1 = 2 3X1 = 3 1X2 = 2 2X2 = 4 3X2 = 6 … … … 1X9 = 9 2X9 = 18 3X9 = 27
时间: 2023-08-15 12:05:58 浏览: 230
好的,下面是C语言代码实现九九乘法表,输出格式为每列三个的形式:
```c
#include <stdio.h>
int main() {
int i, j;
for (i = 1; i <= 9; i++) {
for (j = 1; j <= 3; j++) {
printf("%dX%d = %-2d ", j, i, i*j);
}
printf("\n");
if (i % 3 == 0) {
printf("\n");
}
}
return 0;
}
```
输出结果为:
```
1X1 = 1 2X1 = 2 3X1 = 3
1X2 = 2 2X2 = 4 3X2 = 6
1X3 = 3 2X3 = 6 3X3 = 9
1X4 = 4 2X4 = 8 3X4 = 12
1X5 = 5 2X5 = 10 3X5 = 15
1X6 = 6 2X6 = 12 3X6 = 18
1X7 = 7 2X7 = 14 3X7 = 21
1X8 = 8 2X8 = 16 3X8 = 24
1X9 = 9 2X9 = 18 3X9 = 27
```
希望能帮到你!
相关问题
用c语言输出九九乘法表要求输出三列,输出格式为輸出格式 1X1 = 1 2X1 = 2 3X1 = 3 1X2 = 2 2X2 = 4 3X2 = 6 … … … 1X9 = 9 2X9 = 18 3X9 = 27 4X1 = 4 5X1 = 5 6X1 = 6 4X2 = 8 5X2 = 10 6X2 = 12 … … … 4X9 = 36 5X9 = 45 6X9 = 72 7X1 = 7 8X1 = 8 9X1 = 9 … … … 7X9 = 63 8X9 = 72 9X9 = 81
好的,以下是用 C 语言输出九九乘法表的代码:
```c
#include <stdio.h>
int main() {
int i, j, k;
for (i = 1; i <= 9; i += 3) {
for (j = 1; j <= 9; j++) {
for (k = i; k < i + 3; k++) {
printf("%dX%d = %-3d ", k, j, k * j);
}
printf("\n");
}
printf("\n");
}
return 0;
}
```
输出结果为:
```
1X1 = 1 2X1 = 2 3X1 = 3
1X2 = 2 2X2 = 4 3X2 = 6
1X3 = 3 2X3 = 6 3X3 = 9
1X4 = 4 2X4 = 8 3X4 = 12
1X5 = 5 2X5 = 10 3X5 = 15
1X6 = 6 2X6 = 12 3X6 = 18
1X7 = 7 2X7 = 14 3X7 = 21
1X8 = 8 2X8 = 16 3X8 = 24
1X9 = 9 2X9 = 18 3X9 = 27
4X1 = 4 5X1 = 5 6X1 = 6
4X2 = 8 5X2 = 10 6X2 = 12
4X3 = 12 5X3 = 15 6X3 = 18
4X4 = 16 5X4 = 20 6X4 = 24
4X5 = 20 5X5 = 25 6X5 = 30
4X6 = 24 5X6 = 30 6X6 = 36
4X7 = 28 5X7 = 35 6X7 = 42
4X8 = 32 5X8 = 40 6X8 = 48
4X9 = 36 5X9 = 45 6X9 = 54
7X1 = 7 8X1 = 8 9X1 = 9
7X2 = 14 8X2 = 16 9X2 = 18
7X3 = 21 8X3 = 24 9X3 = 27
7X4 = 28 8X4 = 32 9X4 = 36
7X5 = 35 8X5 = 40 9X5 = 45
7X6 = 42 8X6 = 48 9X6 = 54
7X7 = 49 8X7 = 56 9X7 = 63
7X8 = 56 8X8 = 64 9X8 = 72
7X9 = 63 8X9 = 72 9X9 = 81
```
希望能对您有所帮助!
用c语言打印九九乘法表
Sure, here's the code to print the multiplication table in C:
```
#include <stdio.h>
int main() {
int i, j;
for (i = 1; i <= 9; i++) {
for (j = 1; j <= i; j++) {
printf("%d*%d=%d\t", j, i, i*j);
}
printf("\n");
}
return 0;
}
```
This will print out the multiplication table from 1x1 to 9x9.
阅读全文