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;

}

相关推荐
CRMEB系统商城12 分钟前
CRMEB多商户系统(PHP)- 移动端二开之基本容器组件使用
运维·开发语言·小程序·php
淮北49416 分钟前
科研绘图工具R语言
开发语言·r语言
逍遥德22 分钟前
java Map Set List 扩容机制
java·开发语言·list
2501_9445215928 分钟前
Flutter for OpenHarmony 微动漫App实战:图片加载实现
android·开发语言·前端·javascript·flutter·php
nbsaas-boot29 分钟前
基于 Java 21 ScopedValue 的多租户动态数据源完整实践
java·开发语言
liuc031735 分钟前
Java项目关于不同key的读取
java·开发语言
博大世界1 小时前
matlab结构体数组定义
数据结构·算法
txinyu的博客1 小时前
前置声明与 extern
linux·c++
Loo国昌1 小时前
【LangChain1.0】第九阶段:文档处理工程 (LlamaIndex)
人工智能·后端·python·算法·langchain
Zach_yuan1 小时前
面向对象封装线程:用 C++ 封装 pthread
开发语言·c++·算法