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;

}

相关推荐
imuliuliang2 小时前
关于数据结构在算法设计中的核心作用解析7
算法
code_pgf2 小时前
C++11 / C++14 / C++17 / C++20 新特性总结
c++·c++20
魔力女仆2 小时前
分享一个 JS 鼠标跟随贪吃蛇背景库
开发语言·javascript·计算机外设
2401_894915533 小时前
GEO 搜索优化完整源码从零部署:环境配置、集群搭建全流程
开发语言·python·tcp/ip·算法·unity
麻瓜老宋3 小时前
AI开发C语言应用按步走,表达式计算器calc的第二十二步,分号赋值链式修复、TOKEN_ASSIGN
c语言·开发语言·atomcode
普通网友4 小时前
共识算法实现:从工作量证明到权益证明的演进
算法·区块链·共识算法
颜x小5 小时前
[C#] C++与c#语法对比
开发语言·c++·c#
ldmd2845 小时前
地图生成算法(噪声篇-Perlin,Simplex,Value noise)
算法·go·地图生成
weixin_423652136 小时前
C#使用JObject
开发语言·c#