#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
//参数是数组形式
void print1(int arr[3][5], int x, int y)//用数组形式接收,再接收传来的参数
{
int i = 0;
int j = 0;
for (i = 0; i < x; i++)
{
for (j = 0; j < y; j++)
{
printf("%d ",arr[i][j]);
}
printf("\n");
}
}
//参数是指针形式
void print2(int(*p)[5], int x, int y)
{
int i = 0;
int j = 0;
for (i = 0; i < x; i++)
{
for (int j = 0; j < y; j++)
{
printf("%d ",*(*(p+i)+j));
}
printf("\n");
}
}
int main()
{
int arr[3][5] = { {1,2,3,4,5},{2,3,4,5,6},{3,4,5,6,7} };
print1(arr,3,5);//将数组名和数组元素进行传参
print2(arr, 3, 5);
return 0;
}
标签:print1,arr,int,用法,++,数组,printf,指针
From: https://blog.51cto.com/u_16425777/9058438