字符串排序 输入3个字符串,将它们按照字母由大到小排序(代码实例)

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

字符串排序 输入3个字符串,将它们按照字母由大到小排序(代码实例)

  2021-03-20 我要评论
想了解输入3个字符串,将它们按照字母由大到小排序(代码实例)的相关内容吗,在本文为您仔细讲解字符串排序的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:字符串,排序,下面大家一起来学习吧。

用string方法定义字符串变量

实现代码:

复制代码 代码如下:

#include<iostream>
#include<string>
using namespace std;
int main(){
 string a,b,c,t;
 cout<<"please input first string:"<<endl;
 cin>>a;
 cout<<"please input second string:"<<endl;
 cin>>b;
 cout<<"please input third string:"<<endl;
 cin>>c;
 if(a>b){
  t=a;
  a=b;
  b=t;
 }
 if(a>c){
  t=a;
  a=c;
  c=t;
 }
 if(b>c){
  t=b;
  b=c;
  c=t;
 }
 cout<<a<<"<<"<<b<<"<<"<<c<<endl;   
 return 0; 
}

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们