Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language programming two-dimensional array outputs a 2*3 matrix
C language programming two-dimensional array outputs a 2*3 matrix

#include

void main()

{

int a[2][3];< /p>

int i,j;

printf("Enter a 2*3 integer array\n");

for(i=0;i<2 ;i++)

for(j=0;j<3;j++)

scanf("%d",&a[i][j]);

< p>printf("\nOutput a 2*3 integer array\n");

for(i=0;i<2;i++)

{

for(j=0;j<3;j++)

printf("%d ",a[i][j]);

printf("\ n");

}

}

Extended information:

Notes

C language input The input and output functions in the standard library can be used for output, namely scanf and printf.

Example of input and output two-dimensional array:

#include

int main()

{

int M = 5, N = 5;?

int? array[M][N]; //Define a 5x5 int array

printf(" Input: ");?

for(int i = 0; i < M; i++){

for(int j = 0; j < N; j++){

scanf("%d",&array[i][j]);

}

}

printf("Output:" );?

for(int i = 0; i < M; i++){

for(int j = 0; j < N; j++){

< p>printf("%d ",array[i][j]);

}

}

return 0;

}