// 121221 上机任务2.cpp : 定义控制台应用程序的入口点。
//
/*
* Copyright (c) 2012, 烟台大学计算机学院
* All rights reserved.
* 作 者: 刘同宾
* 完成日期:2012 年 12 月 21 日
* 版 本 号:v1.0
* 输入描述:
* 问题描述:引用类型作参数,排序
* 程序输出:
* 问题分析:略
* 算法设计:略
*/
#include "stdafx.h"
#include<iostream>
using namespace std;
int main()
{
void sort(int &a,int &b,int &c);
int a=7,b=1,c=4;
sort(a,b,c);
cout<<"从小到大顺序为:"
<<a<<" "<<b<<" "<<c<<endl;
return 0;
}
//对3个整数排序 函数
void sort(int &a,int &b,int &c)//引用作形参
{
int temp;
if(a>b)
{
temp=a;
a=b;
b=temp;
}
if(a>c)
{
temp=a;
a=c;
c=temp;
}
if(b>c)
{
temp=b;
b=c;
c=temp;
}
}
引用类型作参数,排序
最新推荐文章于 2019-12-02 17:09:00 发布