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;

}

相关推荐
怕浪猫4 小时前
RAG 面试 6 连问,从原理到优化全部覆盖
python·算法·面试
无线通信科研笔记4 小时前
IEEE TVT 2026 论文精读与完整复现|相位误差如何重塑近场 RIS 的幅相响应
论文阅读·人工智能·python·算法·论文笔记
2601_962885725 小时前
如何用 Python 自动识别股票的支撑位与压力位?
开发语言·python
mmmmath_35 小时前
二叉树の递归遍历
算法
爱吃奥利奥_wen5 小时前
面向对象三板斧:封装、继承、多态,到底在“装“什么、“承“什么、“变“什么?
开发语言·经验分享·c#
All for pursuit.6 小时前
【位运算-1】338.比特位计数
数据结构·c++·算法·leetcode
我可能是个假开发6 小时前
FTP Unicode 文件名导致 `550` 的问题分析与解决方案
java·开发语言·spring
小师兄吃牛肉6 小时前
C语言中的nullptr有必要吗
c语言·c++·算法
WL学习笔记7 小时前
日期类(C++)
开发语言·c++·日期类实现
谢亮_vipxieliang8 小时前
Go map与结构体的正确使用
开发语言·golang·哈希算法