C language: Use malloc to open up a 3*4 two-dimensional array and initialize the content to 1-12.
Method 1:
# Include <stdio. h> # include <stdlib. h> int main () {int (* p) [4] = (int (*) [4]) malloc (12 * sizeof (int )); // array pointer for (int I = 0; I <3; I ++) {for (int j = 0; j <4; j ++) {* (p + I) + j) = I * 4 + j + 1 ;}} for (I = 0; I <3; I ++) {for (j = 0; j <4; j ++) {printf ("% d \ t", * (p + I) + j ));}} printf ("\ n"); system ("pause"); return 0 ;}
Method 2:
#include<stdio.h>#include<stdlib.h>int main(){ int i = 0; int j = 0; int **p = (int **)malloc(3 * sizeof(int)); for (i = 0; i < 3; i++) { *(p + i) = (int *)malloc(4 * sizeof(int)); } for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { p[i][j] = 4 * i + j + 1; } } for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { printf("%d ", *(*(p + i) + j)); } } system("pause"); return 0;}