string字符串的比较
比较运算符有
= < <= ==
“123” < “1230” 真
“19” > “123456789” 真
“2” > “1999” 真
“123” == “123” 真
“123” == “1230” 假
代码实现
#include
#include <Windows.h>
#include
using namespace std;
int main(void) {
string myGirl = “Lisa”;
string youGirl;
cout<<“我的女朋友是”<<myGirl<<endl;
cout<<“你的女朋友是?”<<endl;
cin>>youGirl;
if(myGirl==youGirl){
cout<<"她是一个海王"<<endl;
}else{
cout<<"祝你幸福"<<endl;
}
system("pause");
return 0;
}