c++中的string 中对象的大小比较

 1 #include<iostream>
 2 using namespace std;
 3 
 4 int main()
 5 
 6 {
 7 
 8 string str1=("124");
 9 string str2=("531");
10 string str3="1234";
11 bool answer;
12 answer=str1>str2;
13 cout<<answer<<endl;    //0   从第一个不同的数字或者字母比较大小
14 
15 answer=str3>str1;    
16 cout<<answer<<endl;     //0
17 answer=str2>str3;
18 cout<<answer<<endl;      //1
19 return 0;
20 
21 }

 

posted @ 2018-09-28 22:02  spring-go  阅读(4567)  评论(0)    收藏  举报