通过自定义函数实现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; }
相关文章推荐
- ASP.NET通过自定义函数实现对字符串的大小写切换功能
- 简单的通过宏定义实现自定义打印函数
- Lua 具名实参(通过table实现可选参数函数)
- Android中GridView通过自定义适配器(未优化)实现图文视图排列
- Android中GridView通过自定义适配器(未优化)实现图文视图排列
- ASP.NET通过自定义函数实现对字符串的大小写切换功能
- 通过函数分配内存,理解实参,形参之间的传递.
- JavaScript中函数的形参和实参的实现原理剖析
- JavaScript中函数的形参和实参的实现原理剖析
- 【代码】结构体做函数参数,实现形参向实参传递值
- 第7课 Python自定义函数基础:有形参和实参解析
- 不能通过改变形参指针的值(形参所指向的地址)来改变实参指针的地址,实现改变实参指针所指向地址变量的值。
- 自定义View通过PorterDuffXfermode实现图片遮罩效果
- Python实现自定义函数的5种常见形式分析
- 自绘实现半透明水晶按钮(继承CButton,设置BS_OWNERDRAW风格,覆盖DrawItem函数绘制按钮,把父窗口的背景复制到按钮上,实现视觉上的透明,最后通过AlphaBlend实现半透明)
- 排列搜索 庞果网(C语言版,虽实现了,但未通过测试,时间超过3s,使用的是全排序方法,愿大神指导)
- 通过实现接口ListCellRenderer自定义JList的显示模式
- 自定义排序函数实现时需要注意的问题
- ACCESS中的参数查询与自定义函数的实现
- OpenCV示例学习笔记(1)-contours2.cpp-通过findContours 函数实现轮廓提取