二维数组输入输出C语言
时间: 2023-11-23 10:57:06 浏览: 158
以下是二维数组输入输出的C语言代码示例:
1. 二维数组输入
```c
#include <stdio.h>
int main()
{
int arr[3][3];
int i, j;
printf("Enter elements in the array:\n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
scanf("%d", &arr[i][j]);
}
}
printf("\nElements in the array are: \n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
}
```
2. 二维数组输出
```c
#include <stdio.h>
int main()
{
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int i, j;
printf("Elements in the array are: \n");
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
}
```
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![c](https://img-home.csdnimg.cn/images/20250102104920.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pptx](https://img-home.csdnimg.cn/images/20241231044947.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pptx](https://img-home.csdnimg.cn/images/20241231044947.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pptx](https://img-home.csdnimg.cn/images/20241231044947.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044937.png)