题解 | 比较字符串大小

#include <iostream>
#include <string>
using namespace std;

int mystrcmp(const string src, const string  dst);

int main() 
{
    string src, dst;

    // 从键盘读取两个字符串
    getline(cin, src);
    getline(cin, dst);
    int ret= mystrcmp(src,dst);
    cout<<ret<<endl;
    return 0;
}
    
int mystrcmp(const string src, const string dst){
    int res=0;
    if (src < dst) 
    {
        return -1;
    } 
    else if (src > dst) 
    {
        return 1;
    } 
    else 
    {
        return 0;
    }

    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 12:05
点赞 评论 收藏
分享
完美的潜伏者许愿简历...:隐藏信息被你提取出来了,暗示,这就是暗示
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务