写c++程序:从键盘上输入一组数据,其中该组数据是以输入零结束的,求这组数中最大值与最小值

2024-11-22 08:09:50
推荐回答(1个)
回答1:

// 必须要以零结尾,但中间不能含零
#include
void main()
{
int num, max, min;
cin>>num;
if (num!=0)
{
max = num;
min = num;
while(num!=0)
{
if (num > max) max = num;
if (num < min) min = num;
cin>>num;
}
cout<<"max number : "< cout<<"min number : "<
}
else
{
cout<<"The first number equal zero"< }

}