输入三个字符串,按由小到大的顺序输出
2014-02-25 19:53
537 查看
输入三个字符串,按由小到大的顺序输出
Description
输入三个字符串,按由小到大的顺序输出。分别使用指针和引用方式实现两个排序函数。在主函数中输入和输出数据。
Input
3行字符串
Output
按照从小到大输出成3行。由指针方式实现。
按照从小到大输出成3行。由引用方式实现。
Sample Input
cde
afg
abc
Sample Output
abc
afg
cde
abc
afg
cde
Description
输入三个字符串,按由小到大的顺序输出。分别使用指针和引用方式实现两个排序函数。在主函数中输入和输出数据。
Input
3行字符串
Output
按照从小到大输出成3行。由指针方式实现。
按照从小到大输出成3行。由引用方式实现。
Sample Input
cde
afg
abc
Sample Output
abc
afg
cde
abc
afg
cde
#include<iostream> #include<string> using namespace std; void swap(string &a,string &b); int main() { string a,b,c; cin>>a>>b>>c; if(a>b) swap(a,b); if(b>c) swap(b,c); if(a>b) swap(a,b); cout<<a<<endl; cout<<b<<endl; cout<<c<<endl; return 0; } void swap(string &a,string &b) { string c; c=a; a=b; b=c; }
相关文章推荐
- usaco training 4.1.2 Fence Rails 题解
- mvn eclipse:eclipse -Dwtpversion=2.0 -DdownloadSources=true -DdownloadJavadocs=true -DjdkLevel=1.6
- QtableWidget的用法
- 并查集C - More is better
- 有进位和没进位
- Struts2中的路径问题
- 模型转化
- windows batch 常用命令
- USACO各种思想好题归纳
- 将博客搬至CSDN
- java常见机试题目(1)
- CSDN移动博文集锦
- LayoutInflater的inflate函数用法详解
- Html页面清除缓存
- 字符串和数字之间的转换
- 本地事务处理
- Linux守护进程工作原理和方式----笛风读书笔记系列
- URL Rewrite
- 动态规划之矩阵连乘
- cocos2dx 文件处理