定义一个2行3列的整型二维数组,并随意赋初值,用指针操作求每一行的和并输出。
1个回答
展开全部
#include <stdio.h>
#define N 5
#define M 5
void main(void)
{
int a[N][M]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
int *arr[N]={a[0],a[1],a[2],a[3],a[4]};
int i,j,**p=arr;
for(i=0;i<N;i++)
{
for(j=0;j<M;j++)
printf("%3d",*(*(p+i)+j));
printf("\n");
}
}
#define N 5
#define M 5
void main(void)
{
int a[N][M]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
int *arr[N]={a[0],a[1],a[2],a[3],a[4]};
int i,j,**p=arr;
for(i=0;i<N;i++)
{
for(j=0;j<M;j++)
printf("%3d",*(*(p+i)+j));
printf("\n");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询