您的位置:首页 > 其它

通过自定义函数实现3个数的排列,形参和实参!

2012-12-21 13:16 369 查看
/*
* 程序的版权和版本声明部分
* Copyright (c)2012, 烟台大学计算机学院学生
* All rightsreserved.
* 文件名称: x.cpp
* 作者:徐本锡
* 完成日期: 2012年 12 月20  日
* 版本号: v1.0
* 输入描述:

* 问题描述:设计一个程序,输入3 个整数,将其按从大到小的顺序输出,要求
排序功能通过函数实现

* 程序输出:

*/
//我的代码:
#include <iostream>
using namespace std;
void paixu(int *a,int*b,int*c);//从大到小排序
int main(void)
{
int a,b,c;
cin>>a>>b>>c;
paixu(&a,&b,&c);
cout<<"从大到小输出为:";
cout<<a<<"	"<<b<<"	"<<c<<"	"<<endl;
return 0;
}
void paixu(int *a,int*b,int*c)//从大到小排序
{
int t;
if(*a<*b){t=*b;*b=*a;*a=t;}
if(*a<*c){t=*c;*c=*a;*a=t;}
if(*b<*c){t=*c;*c=*b;*b=t;}
return;

}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐