1.题目要求如下:
C++用带有默认参数的函数实现,求2个或3个正整数中的最大数
2.来吧,展示:
#include <iostream>
using namespace std;
void sort(int a,int b)
{
    int temp;
    if (a>b){temp = a;a = b;b = temp;}
    cout <<a<< ',' <<b<<endl;
}
void sort(float x,float y,float z)
{
    float temp;
    if(x>y){temp=x;x=y;y=temp;}
    if(z<x) cout <<z<< ',' <<x<< ',' <<y<< endl;
        else if(z<y) cout <<x<< ',' <<z<< ',' <<y<< endl;
            else cout <<x<< ',' <<y<< ',' <<z<< endl;
}
int main()
{
    void sort(int a,int b);
    void sort(float x,float y,float z);
    float x,y,z;
    int a,b;
    cout <<"请输入两个整数:"<<endl;
    cin >>a>>b;
    cout << "排序从小到大为:" << endl;
    sort(a,b);
    cout <<"请输入三个浮点数:"<<endl;
    cin >>x>>y>>z;
    cout << "排序从小到大为:" << endl;
    sort(x,y,z);
    return 0;
}3.运行结果如下:
     
   
    希望能帮到大家,问你们要一个赞,你们会给吗,谢谢大家
    
    版权声明:本文版权归作者(@攻城狮小关)和CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    
    大家写文都不容易,请尊重劳动成果~
    
    交流加Q:1909561302
    
    博客园地址https://www.cnblogs.com/guanguan-com/
   
 
版权声明:本文为Mumaren6原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
