zoukankan      html  css  js  c++  java
  • 输入三个字符串,按由小到大的顺序输出

    输入三个字符串,按由小到大的顺序输出
    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;
    }


  • 相关阅读:
    Mac + Python3 安装scrapy
    Pyqt4+Eric6+python2.7.13(windows)
    js基础⑥
    python模块之os,sys
    Python模块之random
    Python模块之PIL
    js基础⑤
    js基础④
    js基础③
    centOS目录结构详细版
  • 原文地址:https://www.cnblogs.com/oversea201405/p/3766973.html
Copyright © 2011-2022 走看看