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;

}

相关推荐
神仙别闹8 分钟前
基于QT(C++)+Sqlite3实现单词消除游戏系统
c++·qt·sqlite
AllData公司负责人8 分钟前
亲测丝滑,体验跃迁|AllData通过集成开源项目RustFS,多模态数据存储新范式
java·大数据·数据库·算法·数据分析·rustfs
磊 子12 分钟前
AVL树的讲解
数据结构·算法
至为芯13 分钟前
IP5356H_G3至为芯支持C口双向快充22.5W新国标移动电源方案芯片
c语言·开发语言
yunn_14 分钟前
基于C++ 11的线程池实现
c++
skywalk816317 分钟前
python run.py “请讨论一下中文编程语言的设计“ --max-rounds 4
开发语言·人工智能
Trouvaille ~18 分钟前
【Redis篇】Hash 哈希:字段级操作与对象存储的最佳实践
数据库·redis·后端·算法·缓存·哈希算法·键值对
辞忧九千七25 分钟前
吃透Redis7核心数据结构:从基础用法到实战场景(Python版)
开发语言·数据结构·redis·python
悠仁さん26 分钟前
数据结构 树 二叉树 堆 (链式二叉树模拟实现篇)
数据结构·算法