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;

}

相关推荐
Daniel_12314 小时前
数组——总结篇
算法
炸薯条!14 小时前
从零开始学C++ (内存管理)
java·jvm·c++
不懒不懒14 小时前
【针对路面识别数据集,结合三轴加速度标准化数据及多路面识别需求,以下是算法选择与处理方案】
算法
Reart14 小时前
Leetcode 121. 买卖股票的最佳时机(717)
后端·算法
会编程的小孩14 小时前
初识数据类型以及变量定义
数据结构·算法
Reart14 小时前
Leetcode 337.打家劫舍3(717)
后端·算法
梅梅绵绵冰14 小时前
数据结构-时间复杂度
数据结构·算法
遥感知识服务14 小时前
盐碱地、白屋顶和裸土都很亮,卫星怎样分清?
人工智能·算法·机器学习
可编程芯片开发15 小时前
基于PID控制器的车辆控制系统simulink建模与仿真
算法
广州灵眸科技有限公司15 小时前
瑞芯微RV1126B开发板(EASY-EAI-PI2) 系统操作-线进程操作
数据库·单片机·嵌入式硬件·算法·php