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;

}

相关推荐
v:PLLucky2015 小时前
农作物病虫害检测识别系统
深度学习·scrapy·算法·百度·微信公众平台
朝朝辞暮i15 小时前
C++ 第一阶段总结:从零基础到 ROS2 前置语法
开发语言·c++·算法
朝朝辞暮i15 小时前
C++ 第 25 课:getter / setter + this
java·javascript·c++
2601_9628857215 小时前
如何用 Python 回测定投策略(定期定额 DCA)?(和一次性买入对比)
开发语言·人工智能·python
H.莓飛15 小时前
【数据结构】链表_OJ题
linux·数据结构·算法·链表
周杰偷奶茶15 小时前
【JavaSE】类和对象基础
java·开发语言
All for pursuit.15 小时前
【回溯-4】46.全排列
数据结构·c++·算法·leetcode
小鱼~~15 小时前
Recall@K、Precision@K、MRR、nDCG@K简介
人工智能·算法·机器学习
在所不辞兄15 小时前
【零基础学智能仿真-38】从规则矩形到带孔薄板:Gmsh 网格与 FEniCSx 联合求解
人工智能·深度学习·算法·机器学习·工程仿真
大圣编蚕15 小时前
C语言核心知识复习:预处理、头文件、强制类型转换、错误处理、递归与内存管理
c语言·开发语言