题目1466:蓝桥杯基础练习VIP-字符串对比

#include<iostream>

#include<string>

#include<cctype>//tolower(),toupper()的头文件

using namespace std;

int check(const string& str1,const string& str2){

int len1=str1.length();

int len2=str2.length();

if(len1!=len2){

return 1;

}

bool isEqual=true;

if(len1==len2){

for(int i=0;i<len1;i++){

if(str1i!=str2i){

isEqual=false;

break;

}

}

if(isEqual){

return 2;

}

}

for(int i=0;i<len1;i++){

if(tolower(str1i)!=tolower(str2i)){

return 4;

}

}

return 3;

}

int main(){

string str1,str2;

cin>>str1>>str2;

int result=check(str1,str2);

cout<<result<<endl;

return 0;

}

相关推荐
dialect_8 小时前
KMP算法
开发语言·c++·算法
reikocao8 小时前
卡尔曼滤波的动态机制:P如何改变融合权重
算法
漂流瓶jz9 小时前
UVA-1612 猜名次 题解答案代码 算法竞赛入门经典第二版
数据结构·算法·题解·排序·aoapc·算法竞赛入门经典
吞下星星的少年·-·9 小时前
Div.2 CF 1130B题(构造,贪心)
算法·贪心·构造
ShineWinsu10 小时前
对于Qt:QRadioButton常见属性以及QButtonGroup的解析
数据库·c++·qt·microsoft·gui·qradiobutton·qbuttongroup
傲世仙尊10 小时前
多态-虚表才活到运行期符号表早已消失
c++
chenbingjie_c10 小时前
C++ 多态完全指南:从虚函数重写到虚函数表原理
开发语言·c++
是main不是漫10 小时前
【双指针——移动零】数组划分类题目的入门基石
c++·算法
·present·11 小时前
CSAPP(Bomb lab)
c语言·c++
王老师青少年编程11 小时前
2026年信奥赛c++普及组csp-j第二轮复赛真题
c++·真题·csp·信奥赛