current position:Home>Use the pointer of the array to test the relationship between the two-dimensional elements and the column of the array in the order of "% 1-6", and then use the pointer of the array to output the data in the order of "% 1-6", and then use the pointer of t

Use the pointer of the array to test the relationship between the two-dimensional elements and the column of the array in the order of "% 1-6", and then use the pointer of the array to output the data in the order of "% 1-6", and then use the pointer of t

2022-04-29 14:29:57Tomatos_ baby

Function interface definition :

void reOut(int (*p)[3]);

Sample referee test procedure :

#include <stdio.h>
int main()
{
    void reOut(int (*p)[3]);
    int i, j, a[2][3], (*p)[3];
    for (i = 0; i < 2; i++)
        for (j = 0; j < 3; j++)
        scanf("%d", &a[i][j]);
    p= a;
    reOut(p); 
}


/*  Please fill in the answer here  */

sample input :

Here's a set of inputs . for example :

1 2 3
4 5 6

sample output :

  1  2  3
  4  5  6
  1  4
  2  5
  3  6
void reOut(int (*p)[3])
{
    int i,j;
    for(i=0;i<2;i++)
    {
        for(j=0;j<3;j++)
            printf("%3d",*(*(p+i)+j));
        printf("\n");
    }
    for(i=0;i<3;i++)
    {
        for(j=0;j<2;j++)
            printf("%3d",*(*(p+j)+i));
                   printf("\n");
    }
}

 

copyright notice
author[Tomatos_ baby],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291259257546.html

Random recommended