C++——输入3个字符串,按由小到大的顺序输出。用指针或引用方法处理。

没注释的源代码

#include <iostream>

#include <string>

#include <stdio.h>

using namespace std;

void swap(string&str1,string&str2);

int main()

{

string a=" ",

b=" ",

c=" ";

char *p1=&a[0],*p2=&b[0],*p3=&c[0];

cout<<"please input line p1,p2,p3:"<<endl;

gets(p1);

gets(p2);

gets(p3);

if(a>b) swap(a,b);

if(a>c) swap(a,c);

if(b>c) swap(b,c);

cout<<"now the order is:"<<endl<<a<<endl<<b<<endl<<c<<endl;

return 0;

}

void swap(string&str1,string&str2)

{

string temp;

temp=str1;

str1=str2;

str2=temp;

}

相关推荐
荒诞硬汉3 分钟前
面向对象(三)
java·开发语言
2301_773730313 分钟前
系统编程—在线商城信息查询系统
c++·html
郝学胜-神的一滴4 分钟前
深入理解Linux中的Try锁机制
linux·服务器·开发语言·c++·程序人生
liliangcsdn4 分钟前
bash中awk如何切分输出
开发语言·bash
菜鸟233号10 分钟前
力扣416 分割等和子串 java实现
java·数据结构·算法·leetcode
csbysj202011 分钟前
JSON.parse() 方法详解
开发语言
奔波霸的伶俐虫13 分钟前
redisTemplate.opsForList()里面方法怎么用
java·开发语言·数据库·python·sql
Swift社区16 分钟前
LeetCode 469 凸多边形
算法·leetcode·职场和发展
chilavert31818 分钟前
技术演进中的开发沉思-298 计算机原理:算法的本质
算法·计算机原理
yesyesido24 分钟前
智能文件格式转换器:文本/Excel与CSV无缝互转的在线工具
开发语言·python·excel