参考代码如下:
#include
using namespace std;
int main( )
{
int a,b,c,max;
cout<<"请输入n个数值:";
cin>>a>>b>>c;
//先求出a和b的大值
if(a>b)
max=a;
else
max=b;
//再求出c和max的大值
if(c>max)
max=c;
cout<<"最大值是: "<
}
#include
using namespace std;
int main ()
{
int max;
int min;
int temp; //用来保存输入的数
cout<<"please input number,input A end!"<cin>>temp; //输入第一个数
max = temp;
min = temp;
while(cin>>temp) ///循环输入数
{
if(temp>max)
max = temp;
if(tempmin = temp;
}
cout<<"min = "<return 0;
}
#include
#include
#include
using namespace std;
int main ()
{
int number;
vectorall_number;
cout<<"输入数字,按ctrl+z 结束"<while(cin>>number)
{
all_number.push_back(number);
}
auto result = minmax_element (all_number.begin(),all_number.end());
cout<<"最小的数为:"<<*result.first<<" 最大的数为 "<<*result.second<return 0;
}