美文网首页
10.13-7 指针与二维数组copy

10.13-7 指针与二维数组copy

作者: 日常表白结衣 | 来源:发表于2017-07-15 21:00 被阅读0次

    【二维数组全部copy】

    #include<stdio.h>
    #define ROWS 3
    #define COLS 4
    void cpoy_arry(double source [][COLS], double arry [][COLS], int m,int n);
    int main()
    {
        double source[][COLS] = { {1.1,2.2,3.3,0},{4.4,5.5,6.6,0},{7.7,8.8,9.9,0}};
        double arry[ROWS][COLS] = { 0 };
    
        cpoy_arry(source,arry,ROWS,COLS);
        for (int i = 0; i < ROWS; i++)
        {
            for (int j = 0; j < COLS; j++)
            {
                printf("%8.3lf ", arry[i][j]);
            }
            putchar('\n');
        }
        putchar('\n');
    
        getchar();
        getchar();
    
        return 0;
    }
    void cpoy_arry(double source[][COLS], double arry[][COLS], int m,int n)
    {
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
            {
                *(*(arry + i) + j) = *(*(source + i) + j);
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:10.13-7 指针与二维数组copy

          本文链接:https://www.haomeiwen.com/subject/oeyzhxtx.html