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;

}

相关推荐
静心观复3 分钟前
Python 虚拟环境与 pipx 详解
开发语言·python
卷心菜狗5 分钟前
Re.从零开始使用Python构建本地大模型网页智慧聊天机器人
开发语言·python·机器人
AlenTech19 分钟前
647. 回文子串 - 力扣(LeetCode)
算法·leetcode·职场和发展
py有趣23 分钟前
力扣热门100题之合并两个有序链表
算法·leetcode·链表
书到用时方恨少!25 分钟前
Python NumPy 使用指南:科学计算的基石
开发语言·python·numpy
2501_9333295530 分钟前
技术深度拆解:Infoseek舆情系统的全链路架构与核心实现
开发语言·人工智能·分布式·架构
8Qi838 分钟前
LeetCode热题100--45.跳跃游戏 II
java·算法·leetcode·贪心算法·编程
Chan161 小时前
MCP 开发实战:Git 信息查询 MCP 服务开发
java·开发语言·spring boot·git·spring·java-ee·intellij-idea
web前端进阶者1 小时前
Rust初学知识点快速记忆
开发语言·后端·rust
foundbug9991 小时前
基于STM32的步进电机加减速程序设计(梯形加减速算法)
stm32·单片机·算法