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;

}

相关推荐
步菲7 小时前
springboot canche 无法避免Null key错误, Null key returned for cache operation
java·开发语言·spring boot
香蕉卜拿拿拿11 小时前
软件解耦与扩展的利器:基于C++与C#的插件式开发实践
c++
aigcapi11 小时前
RAG 系统的黑盒测试:从算法对齐视角解析 GEO 优化的技术指标体系
大数据·人工智能·算法
知远同学12 小时前
Anaconda的安装使用(为python管理虚拟环境)
开发语言·python
小徐Chao努力13 小时前
【Langchain4j-Java AI开发】09-Agent智能体工作流
java·开发语言·人工智能
CoderCodingNo13 小时前
【GESP】C++五级真题(贪心和剪枝思想) luogu-B3930 [GESP202312 五级] 烹饪问题
开发语言·c++·剪枝
柯慕灵13 小时前
7大推荐系统/算法框架对比
算法·推荐算法
adam-liu13 小时前
Fun Audio Chat 论文+项目调研
算法·语音端到端·fun-audio-chat
kylezhao201913 小时前
第1章:第一节 开发环境搭建(工控场景最优配置)
开发语言·c#
啃火龙果的兔子13 小时前
JavaScript 中的 Symbol 特性详解
开发语言·javascript·ecmascript