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;

}

相关推荐
m沐沐2 分钟前
【深度学习】YOLOv2目标检测算法——改进点、网络结构与聚类先验框解析
人工智能·pytorch·深度学习·算法·yolo·目标检测·transformer
不会就选b6 分钟前
算法日常・每日刷题--<链表>3
数据结构·算法·链表
geovindu33 分钟前
go: Iterative Algorithms
开发语言·后端·算法·golang·迭代算法
学逆向的34 分钟前
汇编——JCC指令
开发语言·汇编·网络安全
mayaairi1 小时前
JS循环语句深度解析:嵌套for、while与do...while
开发语言·前端·javascript
kite01212 小时前
Go语言Map深度解析与最佳实践
开发语言·后端·golang
Zachery Pole3 小时前
CCF-CSP备战NO.7【队列】
算法
闪电悠米3 小时前
力扣hot100-48.旋转图像-转置翻转详解
算法·leetcode·职场和发展
满天星83035773 小时前
【算法】最长递增子序列(三种解法)
算法
hold?fish:palm3 小时前
kv存储主从复制的设计与实现
c++·redis·后端