模板函数sort
来源:互联网 发布:网络情歌对唱110首 编辑:程序博客网 时间:2024/06/11 04:40
//第一周上机实验4.模板函数
#include <iostream>
#include <string>
using namespace std;
template<typename T> //模版声明
void sort( T &one,T &two, T &three)
{
T temp;
if(one<two)//使one 比two大
{temp=two;
two=one;
one=temp;}
if(one<three)//使one 比two大
{temp=three;
three=one;
one=temp;}
if(two<three)//使one 比two大
{temp=three;
three=two;
two=temp;}
//cout<<one<<two<<three<<endl; //证明参数没有传出去,改成引用
}
int main() {
int i1,i2,i3;
cin>>i1>>i2>>i3;
sort(i1,i2,i3);
cout<<i1<<i2<<i3<<endl;
double d1,d2,d3;
cin>>d1>>d2>>d3;
sort(d1,d2,d3);
cout<<d1<<d2<<d3<<endl;
string s1,s2,s3;
cin>>s1>>s2>>s3;
sort(s1,s2,s3);
cout<<s1<<s2<<s3<<endl;
return 0;
}
- 模板函数sort
- STL标准模板库以及sort函数
- C++标准模板库sort函数
- sort模板
- C++标准模板库<algorithm>下的函数sort
- sort函数
- sort函数
- sort函数
- sort函数
- sort函数
- sort 函数
- sort函数
- sort函数
- sort()函数
- sort函数
- sort函数
- sort函数
- sort函数
- 转:C语言可变参数实现
- linux 网络字节序
- 求总成绩及平均成绩
- 黑马程序员-切割流和合并流
- codeforces round# 177 div2
- 模板函数sort
- 判断字符类别的函数汇总
- java开发软件的安装和执行环境的设置
- 黑马程序员-对象的序列化和管道流
- The Program of Algorithms ------- Diveide and Conquer ---- Quicksort
- 月份与相应的季节
- 黑马程序员-随机访问及操作基本数据
- [leetcode] Remove Duplicates from Sorted Array II
- 某日是某年的哪一天