#include "OJ.h"
#include <iostream>
/*
功能:对输入的整型数组,输出数组元素中的最大值、最大值的个数、最小值和最小值的个数
输入:int * pInputInteger:整型数组指针
int * InputNum:数组元素个数
输出:int * pMaxValue:数组中最大值
int * pMaxNum:数组中最大值的个数
int * pMinValue:数组中最小值
int * pMinNum:数组中最小值的个数
返回:void
*/
void OutputMaxAndMin(int * pInputInteger, int InputNum, int * pMaxValue, int * pMaxNum, int * pMinValue, int * pMinNum)
{
/*在这里实现功能*/
if(pInputInteger == NULL || InputNum < 1)
return;
*pMaxValue = *pMinValue = pInputInteger[0];
*pMaxNum = *pMinNum = 0;
for(int i = 1;i<InputNum;++i)
{
if(pInputInteger[i]>*pMaxValue)
*pMaxValue = pInputInteger[i];
else if(pInputInteger[i]<*pMinValue)
*pMinValue = pInputInteger[i];
}
for(int i = 0;i<InputNum;++i)
{
if(pInputInteger[i] == *pMaxValue)
++(*pMaxNum);
if(pInputInteger[i] == *pMinValue)
++(*pMinNum);
}
}

被折叠的 条评论
为什么被折叠?



