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;

}

相关推荐
@我漫长的孤独流浪11 分钟前
计算机系统核心概念与性能优化全解析
算法·计算机外设
沐知全栈开发12 分钟前
jQuery Mobile 事件详解
开发语言
如竟没有火炬13 分钟前
接雨水22
数据结构·python·算法·leetcode·散列表
ʚ希希ɞ ྀ22 分钟前
二叉树的锯齿层序遍历
数据结构·算法
知识分享小能手40 分钟前
R语言入门学习教程,从入门到精通,R语言获取数据 (8)
开发语言·学习·r语言
qq_4523962340 分钟前
第十一篇:《性能压测基础:JMeter线程模型与压测策略设计》
java·开发语言·jmeter
June`41 分钟前
高并发内存池如何实现
c++·tcmalloc·内存池
ComputerInBook41 分钟前
C++ 关键字 constexpr 和 consteval 之注意事项
开发语言·c++·constexpr·consteval
澈2071 小时前
二叉搜索树:高效增删查的秘诀
java·开发语言·算法
米啦啦.1 小时前
STL(标准模板库)
开发语言·c++·stl