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;

}

相关推荐
lueluelue473 小时前
LeetCode:链表
算法·leetcode·链表
隐积4 小时前
3.1.7.Qt容器大家族(3):QVariant——万能盒子
开发语言·qt
橘子汽水1686 小时前
Leetcode 23,543合并K个升序链表,二叉树的直径
算法·leetcode·链表
huameinan狮子6 小时前
Adaboost算法原理与计算实例
算法
Tri_Function6 小时前
动态规划DP1(c++)
c++
别怪我很水6 小时前
API中提供了VelocityTracker类用于计算触摸事件MotionEvent的速度,而其内部默认使用的方法就是最小二乘法,本 ...
算法·gitee·最小二乘法
名字还没想好☜6 小时前
Next.js ‘use client‘ 到底加在哪:Server/Client Components 边界与常见报错
开发语言·前端·javascript·react·next.js
初级代码游戏7 小时前
iOS开发 Swift 速记1:变量和基本数据类型
开发语言·ios·swift
酷在前行8 小时前
【R生态】PERMANOVA 进阶实战:距离选择、PERMDISP、两两比较与受限置换(保姆级教程)
开发语言·r语言