#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void InputScore(int *p,int m,int n);
int FindMax(int *p,int m,int n,int *pRow,int *pCol);
int main()
{
int *pScore,m,n,maxScore,row,col;
printf_s("input array size m,n:");
scanf_s("%d,%d",&m,&n,sizeof(m));
pScore = (int *)calloc(m*n,sizeof(int));
if(pScore == NULL)
{
printf_s("No enough memory!\n");
exit(0);
}
InputScore(pScore,m,n);
maxScore = FindMax(pScore,m,n,&row,&col);
printf_s("maxScore = %d,class = %d,number = %d\n",maxScore,row+1,col+1);
free(pScore);
system("pause");
return 0;
}
void InputScore(int *p,int m,int n)
{
int i,j;
printf_s("Input %d*%d array:\n",m,n);
for(i = 0;i < m;i++)
{
for(j = 0;j < n;j++)
{
scanf_s("%d",&p[i*n+j]);
}
}
}
int FindMax(int *p,int m,int n,int *pRow,int *pCol)
{
int i,j,max = p[0];
*pRow = 0;
*pCol = 0;
for(i = 0;i < m;i++)
{
for(j = 0;j < n;j++)
{
if(p[i*n+j] > max)
{
max = p[i*n+j];
*pRow = i;
*pCol = j;
}
}
}
return max;
}
转载于:https://www.cnblogs.com/joyclub/p/4423279.html