// 12_2.cpp : Defines the entry point for the console application.
//
#include <iostream>
using namespace std;
void OutputMaxAndMin(int * pInputInteger, int InputNum, int * pMaxValue, int * pMaxNum, int * pMinValue, int * pMinNum)
{
if (pInputInteger)
{
*pMaxValue = *pMinValue = pInputInteger[0];
int array[1024] ={0};
int array1[1024] ={0};
for(int n=0;n<InputNum;n++)
{
if(pInputInteger[n]>=*pMaxValue)
{
* pMaxValue=pInputInteger[n];
array[* pMaxValue]++;
}
if(pInputInteger[n]<=*pMinValue)
{
* pMinValue=pInputInteger[n];
array1[* pMinValue]++;
}
}
*pMaxNum = array[* pMaxValue];
*pMinNum = array1[* pMinValue];
}
return;
}
int main(int argc, char* argv[])
{
int aInputInteger[] = {1,1,1, 2, 3, 4,4};
int iMaxValue, iMaxNum = NULL, iMinValue, iMinNum;
OutputMaxAndMin(aInputInteger, 9, &iMaxValue, &iMaxNum, &iMinValue, &iMinNum);
cout << iMaxValue << endl;
cout << iMaxNum << endl;
cout << iMinValue << endl;
cout << iMinNum << endl;
return 0;
}
//
#include <iostream>
using namespace std;
void OutputMaxAndMin(int * pInputInteger, int InputNum, int * pMaxValue, int * pMaxNum, int * pMinValue, int * pMinNum)
{
if (pInputInteger)
{
*pMaxValue = *pMinValue = pInputInteger[0];
int array[1024] ={0};
int array1[1024] ={0};
for(int n=0;n<InputNum;n++)
{
if(pInputInteger[n]>=*pMaxValue)
{
* pMaxValue=pInputInteger[n];
array[* pMaxValue]++;
}
if(pInputInteger[n]<=*pMinValue)
{
* pMinValue=pInputInteger[n];
array1[* pMinValue]++;
}
}
*pMaxNum = array[* pMaxValue];
*pMinNum = array1[* pMinValue];
}
return;
}
int main(int argc, char* argv[])
{
int aInputInteger[] = {1,1,1, 2, 3, 4,4};
int iMaxValue, iMaxNum = NULL, iMinValue, iMinNum;
OutputMaxAndMin(aInputInteger, 9, &iMaxValue, &iMaxNum, &iMinValue, &iMinNum);
cout << iMaxValue << endl;
cout << iMaxNum << endl;
cout << iMinValue << endl;
cout << iMinNum << endl;
return 0;
}