基础训练 字符串对比

字符串对比

#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;
}
posted @ 2019-02-06 20:45  A-Little-Nut  阅读(110)  评论(0编辑  收藏  举报