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;

}

相关推荐
人工智能培训8 小时前
人工智能数据安全下的个人信息保护实践方案
大数据·人工智能·算法·生活
one3129 小时前
高精度MEMS电容式倾角传感器:原理、结构与Python三维可视化
开发语言·python
程序员小八7779 小时前
Go 语言特性
开发语言·后端·golang
元启数宇9 小时前
幕墙AI设计算法逻辑:元启数宇如何智能分格
人工智能·算法
宵时待雨9 小时前
优选算法专题16:多源BFS
算法·宽度优先
重生之后端学习9 小时前
53. 最大子数组和[中等]✅
java·数据结构·算法·leetcode·职场和发展
水饺编程10 小时前
第5章,[Win32 章节] :绘图模式
c语言·c++·windows·visual studio
INGNIGHT10 小时前
1908 · 布尔表达式求值(stack单调栈&dfs)
开发语言·c++·算法
এ慕ོ冬℘゜10 小时前
深入理解浏览器全屏 API:从 requestFullscreen 到全屏实战
开发语言·html
lucas_AI10 小时前
把表格压成 64 个 token,长文档问答反而更准了:先找表,再看数
人工智能·深度学习·算法