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=&a0,*p2=&b0,*p3=&c0;

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;

}

相关推荐
鱼鱼不愚与2 小时前
《原来如此 | 第01期:为什么导航软件能预测红绿灯倒计时?》
算法
博客18005 小时前
酷宝的使用方法,超好用的免费界面库,C++、MFC可用
c++·mfc·界面库·库来帮·酷宝
郝学胜_神的一滴6 小时前
CMake 026:属性体系精讲、四大作用域全解 & 实战代码落地
c++·cmake
复杂网络6 小时前
论最小 Agent 计算机的形态
算法
kisshyshy1 天前
🍦 雪糕、食堂、火车厢:三幅漫画吃透栈、队列与链表
javascript·算法
众少成多积小致巨1 天前
JNI (Java Native Interface) 技术手册中文参考指南
android·java·c++
猿人谷1 天前
不只是 CPU 阈值:STAR 如何用 GAT + Transformer 做容器级自动扩缩容?
人工智能·算法
复杂网络1 天前
Stable Diffusion 视觉大模型微调技术深度调研
算法
复杂网络1 天前
基于 Stable Diffusion 架构的视觉大模型代表性工作与原理深度解析
算法
MrZhao4001 天前
Agent Loop 如何用 Hook 扩展:权限、日志与工具拦截
算法