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;

}

相关推荐
AI视觉网奇5 小时前
blender底部对齐
开发语言·python·blender
宠..5 小时前
QComboBox 方法大全
开发语言·qt
晚烛5 小时前
CANN 模型热更新:不停机模型切换与无缝更新实战指南
开发语言·python
谢白羽5 小时前
agent memory论文解析一:解析项目(a-mem)
开发语言·php·论文·agent·a-mem·实际项目
迷渡5 小时前
用 Rust 重写的 Bun 有 13365 个 unsafe!
开发语言·后端·rust
一只叁木Meow5 小时前
电商 SKU 选择器:用算法实现优雅的用户交互
前端·javascript·算法
代码中介商5 小时前
红黑树完全指南:从五条性质到完整插入删除实现
数据结构·算法
JieE2125 小时前
反转链表:从双指针到递归,吃透链表反转的核心逻辑
javascript·算法
吃好睡好便好5 小时前
在Matlab中绘制质点三维运动轨迹图
开发语言·学习·matlab·信息可视化
代码村新手5 小时前
C++-多态
开发语言·c++