#include "OJ.h"
#include<stdio.h>
#include<stdlib.h>
/*
功能:对输入的整型数组,输出数组元素中的最大值、最大值的个数、最小值和最小值的个数
输入: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 (InputNum <= 0 || pInputInteger == NULL)
{
*pMaxNum = 0;
*pMinNum = 0;
*pMaxValue = 0;
*pMinValue = 0;
return ;
}
int i, j;
* pMaxNum = 0;
* pMinNum = 0;
for(i = 0;i<InputNum-1;i++)
for (j = 1;j<InputNum;j++)
{
if (pInputInteger[i] > pInputInteger[j])
{
int temp = pInputInteger[i];
pInputInteger[i] = pInputInteger[j];
pInputInteger[j] = temp;
}
}
* pMaxValue = pInputInteger[InputNum-1];
* pMinValue = pInputInteger[0];
for(i = 0;i<InputNum;i++)
{
if(* pMinValue == pInputInteger[i])
(* pMinNum)++;
else if(* pMaxValue == pInputInteger[i])
(* pMaxNum)++;
}
return;
}
#include<stdio.h>
#include<stdlib.h>
/*
功能:对输入的整型数组,输出数组元素中的最大值、最大值的个数、最小值和最小值的个数
输入: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 (InputNum <= 0 || pInputInteger == NULL)
{
*pMaxNum = 0;
*pMinNum = 0;
*pMaxValue = 0;
*pMinValue = 0;
return ;
}
int i, j;
* pMaxNum = 0;
* pMinNum = 0;
for(i = 0;i<InputNum-1;i++)
for (j = 1;j<InputNum;j++)
{
if (pInputInteger[i] > pInputInteger[j])
{
int temp = pInputInteger[i];
pInputInteger[i] = pInputInteger[j];
pInputInteger[j] = temp;
}
}
* pMaxValue = pInputInteger[InputNum-1];
* pMinValue = pInputInteger[0];
for(i = 0;i<InputNum;i++)
{
if(* pMinValue == pInputInteger[i])
(* pMinNum)++;
else if(* pMaxValue == pInputInteger[i])
(* pMaxNum)++;
}
return;
}