Problem F: 多少个最大值?
Time Limit: 1 Sec
Memory Limit: 128 MB
Submit: 1029
Solved: 658
Description
输入若干个int类型的整数,求它们的最大值及其个数。
Input
输入 若干个int类型的整数,至文件尾为止。
Output
输出只有一行:There are # maximum number &.
其中#是最大值的个数,&是最大值。
Sample Input
1 2 3 4 5 6 6 5 4 3 2 1 6 6 6
Sample Output
There are 5 maximum number 6.
HINT
不能使用数组。
Append Code
한국어< 中文 فارسی English ไทย All Copyright Reserved 2010-2011 SDUSTOJ TEAM
GPL2.0 2003-2011 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <list>
using namespace std;
int main()
{
list <int>::iterator p;
list <int>li;
int x;
while(scanf("%d",&x) != EOF)
{
li.push_back(x);
}
li.sort();
int num = 0;
int temp = li.back();
for(p = li.begin(); p != li.end(); p++)
if(*p == temp)
num++;
cout << "There are " << num << " maximum number " << li.back() << ".";
}