基础训练 字符串对比

字符串对比

#include<iostream>
#include<string>
using namespace std;
int main(){
	string s1, s2;
	cin>>s1>>s2; 
	if(s1==s2)
		cout<<2<<endl;
	else if(s1.size()==s2.size()){
		int flag=0;
		for(int i=0; i<s1.size(); i++)
			if(tolower(s1[i])!=tolower(s2[i])){
				flag=1;
				break;
			}
		if(flag==0) cout<<3<<endl;
		else cout<<4<<endl;
	}else
		cout<<1<<endl;
	return 0;
}
原文地址:https://www.cnblogs.com/A-Little-Nut/p/10354060.html