首页 > 编程语言 > 详细

C语言——创建动态二维数组

时间:2021-02-01 21:46:38      阅读:45      评论:0      收藏:0      [点我收藏+]
int main() {
    int **a;
    int row, column;
    int count = 0;
    scanf("%d%d", &row, &column);
    a = (int **)malloc(row * sizeof(int *));
    for (int i = 0; i < row; i++) {
        a[i] = (int *)malloc(column * sizeof(int));
    }

    for (int y = 0; y < row; y++) {
        for (int x = 0; x < column; x++) {
            a[y][x] = count++;
            printf("%d ", a[y][x]);
        }
        printf("\n");
    }
}

 

C语言——创建动态二维数组

原文:https://www.cnblogs.com/Ping697/p/14359019.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!