L1-079 天梯赛的善良

一、题目

L1-079 天梯赛的善良_第1张图片

二、解题思路

  1. 求最大值和最小值以及它们的个数。
  2. 赋初值 max=0,min=1000005 ,因为能力值大于 0 ,小于等于 1000000 。

三、代码

#include
using namespace std;
int main()
{
	int n,max=0,min=1000005,maxcot,mincot;
	cin>>n;
	while(n--)
	{
		int t;
		cin>>t;
		if(tmax)
		{
			max=t;
			maxcot=1;
		}
		else if(t==max)
		{
			maxcot++;
		}
	}
	cout<

四、总结

        最大值和最小值可能相同。

你可能感兴趣的:(c++)