Inspirational as few code to do efficient expression
Reserve knowledge:
1, the conversion capitalization → the cctype header file functions Detailed
important point:
1, this question required four layers of nested if statements, there must be clear, easy to understand, in order to quickly solve problems.
3, the third point is judged, by #include<cctyp>
the toupper()
function of all the characters in the two strings all converted to uppercase, and then determine whether two strings are equal, we can easily solve this problem. This method is called "standardization."
Code:
#include<bits/stdc++.h> //万能头文件
using namespace std;
int main() {
string s1, s2; cin >> s1 >> s2;
if(s1.length() != s2.length()) cout << 1;
else {
if(s1 == s2) cout << 2;
else {
for(int i = 0; i < s1.length(); i++) {
s1[i] = toupper(s1[i]); s2[i] = toupper(s2[i]); }
if(s1 == s2) cout << 3;
else cout << 4;
}
}
return 0;
}