数字比较大小 程序不同 运行差异

来源:互联网 发布:网络上db是什么意思 编辑:程序博客网 时间:2024/06/10 14:56
     /*

     *   copyright     (c)   2014   ,    烟台大学计算机学院

     *   all  rights   reserved  .

     *   文件名称   :    textst  .    cpp

     *    作者  :    孙旭明

     *     完成日期    :    2015年3月12日

     *     版本号    :     v1.0

     *    问题描述:        数值比较,求最大值

      *     输出结果:      一个整数

      */

#include <iostream>

using namespace std;

int main()
{
   int a,b,max;
   cin>>a>>b;
   if (a>b)
    max=a;
   else
    max=b;
   cout<<"max="<<max<<endl;
    return 0;
}

 

 

 

 

#include <iostream>

using namespace std;


int  max ( int x,int y)
{
    int z;
    if (x>y) z=x;
    else z=y;
    return (z);
}
int main()
{
    int a,b,m;
    cin>>a>>b;
    m=max(a,b);
   cout<<"max="<<m<<endl;
    return 0;
}

 

 

 

 

0 0
原创粉丝点击