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=&a[0],*p2=&b[0],*p3=&c[0];

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 小时前
博物馆展览门户|基于Java博物馆展览门户系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot·后端
liulilittle4 小时前
FileStream C++
开发语言·c++·cocoa
Gomiko4 小时前
C/C++基础(五):分支
c语言·c++
wearegogog1235 小时前
光谱分析波段选择的连续投影算法
算法
点PY5 小时前
C++ 中 std::async 和 std::future 的并发性
java·开发语言·c++
执笔论英雄5 小时前
【RL】DAPO 数据处理
算法
不会代码的小猴5 小时前
C++的第九天笔记
开发语言·c++·笔记
CoderYanger5 小时前
Java SE——12.异常(≠错误)《干货笔记》
java·开发语言
Data_agent5 小时前
1688获得1688店铺所有商品API,python请求示例
java·开发语言·python
一晌小贪欢5 小时前
【Python办公】-图片批量添加文字水印(附代码)
开发语言·python·图片水印·python水印·python添加水印·图片添加水印