输入3个字符串,将它们按照字母由大到小排序(示例代码)
输入3个字符串,将它们按照字母由大到小排序(示例代码)
发布时间:2016-12-28 来源:查字典编辑
摘要:用string方法定义字符串变量实现代码:复制代码代码如下:#include#includeusingnamespacestd;intmai...

用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语言学习
编程开发子分类