任意三个数求最大值和最小值

来源:互联网 发布:单机游戏破解软件 编辑:程序博客网 时间:2024/05/01 09:53
/** Copyright(c)2011,烟台大学计算机学院* All right reserved.* 文件名称:test.cpp* 作者: 张凯* 完成日期:2013年10月15日* 版本号: v1.0* 输入描述:* 问题描述:“我”的第一个c++程序,熟悉程序的编辑和运行过程,宣布“我”进入了这个领域* 程序输出:*/#include <iostream>using namespace std;int main(){   int num1,num2,num3,max,min;   cout<<"please enter three numbers:";   cin>>num1>>num2>>num3;   if(num1>num2)   {max=num1;   }   else   {max=num2;   }   if(max>num3)   {cout<<max<<"是最大的数"<<endl;}   else   {cout<<num3<<"是最大的数"<<endl;}      if(num1<num2)   {min=num1;   }   else   {min=num2;}   if(min<num3)   {cout<<min<<"是最小的数"<<endl;}   else   {cout<<num3<<"是最小的数"<<endl;}   return 0;   }


  运行结果(如图):

                                     

                              


  心得体会:菜鸟要开始学走路了,兴奋。