17_1_2_2体会函数参数传递

来源:互联网 发布:js中switch case语句 编辑:程序博客网 时间:2024/05/29 18:15
/** 程序的版权和版本声明部分* Copyright (c)2012, 烟台大学计算机学院学生* All rightsreserved.* 文件名称: zhizhen.cpp* 作    者:纪子龙* 完成日期:2012年12月19日* 版本号: v1.0* 输入描述:无* 问题描述:无*/#include <iostream>using namespace std;void sort(int *x,int *y,int *z);void change(int *x,int *y);int main (){int a,b,c;cout<<"please enter 3 num";cin>>a>>b>>c;sort(&a,&b,&c);    cout<<a<<" "<<b<<" "<<c<<" "<<endl;return 0;}void sort(int *x,int *y,int *z){if(*x<*y)change(x,y);if(*x<*z)            change(x,z);if(*y<*z)change(y,z);}void change(int *i,int *j){int t;t=*i;*i=*j;*j=t;}运行结果:

 

	
				
		
原创粉丝点击