【问题描述】输入若干整数,输入以0结束。输出最大值、最小值以及整数个数(不含最后输入的0)。
【输入形式】以0为结束的若干整数
【输出形式】不包含最后的0的那些整数的最大值,最小值和整数个数
【样例输入】5 9 88 98 2 0
【样例输出】98 2 5
#include <iostream>
using namespace std;
int main()
{
int n,count=0,max=-999999,min = 9999999;
cin>>n;
while(n!=0)
{
if(count==0)
max = min = n;
else
{
if(n>max)
max = n;
if(n<min)
min = n;
}
count++;
cin>>n;
}
cout<<max<<" "<<min<<" "<<count<<endl;
return 0;
}