//判断两个字符串的大小和长度
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1,s2,msg;
string::size_type len1,len2;
cout<<"Input s1 and s2."<<endl;
cin>>s1>>s2;
if(s1==s2)
msg="They are equal.";
len1=s1.size();
len2=s2.size();
if(len1!=len2)
msg=len1>len2?"s1 is longer.":"s2 is longer.";
else
msg="They have same length.";
cout<<msg<<endl;
return 0;
}
Exercice_3.7_判断两个字符串的大小和长度
最新推荐文章于 2023-07-10 14:12:53 发布