#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int a[6][8] = {{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, 26, 27, 28, 29, 30, 31, 32},
{33, 34, 35, 36, 56, 38, 39, 40},
{41, 42, 43, 44, 45, 46, 47, 21}};
int i,j,max;
/*for(i=0;i<6;i++){
for(j=0;j<8;j++){
scanf("%d",&a[i][j]);
}
}*/
int *b=&a[0][0];
max=max1(b);
printf("%d",max);
return 0;
}
int max1(int *b){
int max=*b;
int i,j;
for(i=0;i<6;i++){
for(j=0;j<8;j++){
if(*(b+j+i*8)>max)
max=*(b+j+i*8);
}
}
return max;
}
编程输出二维数组int a[6] b[8]中元素的最大值,要求用指针实现。
最新推荐文章于 2024-07-13 19:20:54 发布