欢迎来到入门教程网!

C语言

当前位置:主页 > 软件编程 > C语言 >

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

来源:本站原创|时间:2020-01-10|栏目:C语言|点击:

用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; 
}

上一篇:C++中指向结构体变量的指针

栏    目:C语言

下一篇:关于数组做函数参数的问题集合汇总

本文标题:输入3个字符串,将它们按照字母由大到小排序(示例代码)

本文地址:https://www.xiuzhanwang.com/a1/Cyuyan/3953.html

网页制作CMS教程网络编程软件编程脚本语言数据库服务器

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:835971066 | 邮箱:835971066#qq.com(#换成@)

Copyright © 2002-2020 脚本教程网 版权所有