用C语言循环语句输出一条4*5的矩阵
时间: 2024-05-15 08:15:59 浏览: 8
```
#include <stdio.h>
int main() {
int i, j;
for(i=1; i<=4; i++) {
for(j=1; j<=5; j++) {
printf("%d ", i*j);
}
printf("\n");
}
return 0;
}
```
输出结果:
```
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
```
相关问题
用c语言代码的循环语句输出******
你可以使用C语言的循环语句来输出一行星号(*)的代码。以下是一个使用for循环的示例代码:
```c
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 6; i++) {
printf("*");
}
return 0;
}
```
这段代码使用for循环来重复打印星号,循环条件是i小于6,每次循环打印一个星号。运行该代码将输出6个星号(******)。
用C语言输出一条4*5的矩阵
```
#include <stdio.h>
int main() {
int matrix[4][5] = {{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20}};
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 5; j++) {
printf("%d ", matrix[i][j]);
}
printf("\n");
}
return 0;
}
```
输出结果:
```
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)