题解 | 比较字符串大小

#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;
}

全部评论

相关推荐

07-10 11:08
门头沟学院 Java
Sairus:我注册都注册不了提醒我手机号二次啥的,果然对于人才推得就是快,像我投完了就没回音的
投递京东等公司9个岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-09 12:10
直接上图
牛客13578115...:改得一般,不值80
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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