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;

}

相关推荐
Dream Cosmos11 小时前
C++ 中 static 关键字的作用与使用规则
linux·c++
路径规划66612 小时前
(MATLAB代码) 船舶轨迹聚类:K-means 算法(260912)
算法·matlab·kmeans
PHP实战开发录12 小时前
PHP脚本手动能跑定时任务却失败
开发语言·php·开发
蒸蒸yyyyzwd13 小时前
cpp 选手秋招学习笔记 day33
c++·笔记·求职招聘
郝学胜-神的一滴13 小时前
Effective Python 条款 10 :海象运算符_=
开发语言·python·程序人生·开源
wuyk55513 小时前
Python零基础入门第十四章:异常处理(try-except)
开发语言·python
wuyk55514 小时前
【Socket 进阶之路】第 3 章 TCP 三次握手 & 四次挥手深度剖析|连接建立、断开、状态机、TIME_WAIT 核心工程问题
服务器·开发语言·网络·物联网·网络协议·tcp/ip
wzdark17 小时前
基于堆的优先队列实现原理与复杂度分析4
算法
彧azz19 小时前
图的存储结构详解:邻接矩阵的原理、实现与应用
开发语言·数据结构·学习·php
老王熬夜敲代码19 小时前
BLAKE3:最快的密码学哈希函数
算法·密码学·哈希算法