A96426/题解
2026-04-13 22:30:45
发布于:广东
16阅读
0回复
0点赞
直接对p[i]以及s[i]进行比较,更高效的做法。
AC代码:
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
int main(){
string s,p;
cin>>s>>p;
for(int j=0;j<s.size();j++){
s[j]=tolower(s[j]);
p[j]=tolower(p[j]);
}
if(s==p)cout<<0;
else if(s<p)cout<<-1;
else cout<<1;
return 0;
}
时间复杂度:O(1) 其实是O(n)
这里空空如也







有帮助,赞一个