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 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM