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;

}

相关推荐
天月风沙12 小时前
基于机器视觉的实验室器件仓储系统设计——内蒙古自治区国家级大创工程存档
开发语言·python
24zhgjx-fuhao12 小时前
虚链路的配置
开发语言·网络·php
weixin_4684668513 小时前
机器学习之决策树新手实战指南
人工智能·python·算法·决策树·机器学习·ai
techdashen13 小时前
Rust 中的小字符串:smol_str 与 smartstring 的对决
开发语言·后端·rust
wanghu202413 小时前
ABC460_E题题解
c++·算法
z2005093013 小时前
今日算法(回溯子集)
数据结构·算法·leetcode
devilnumber13 小时前
java自定义事件处理器极简版:「外卖点餐」场景
java·开发语言
Hesionberger13 小时前
巧用异或找出唯一数字(多解)
java·数据结构·python·算法·leetcode
小何code13 小时前
C语言【初阶】第1节,初识C语言
c语言·开发语言
代码小书生13 小时前
getpass,一个安全输入的 Python 库!
开发语言·python·安全