王品


私信TA

用户名:wangpin

访问量:18561

签 名:

等  级
排  名 495
经  验 4462
参赛次数 1
文章发表 41
年  龄 21
在职情况 学生
学  校 安徽师范大学皖江学院
专  业 软件工程

  自我简介:

 

0.0分

4 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区

您好,整了好一会儿发现用getline()输入字符串就会报 错误20%,想请教一下楼上有碰到过吗?
下面是我的代码:
#include <iostream>
#include <cctype> 
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    string a, b;
    getline(cin, a);
    getline(cin, b);
    if (a.size() != b.size())
        cout << 1 << endl;
    else if (a == b)
        cout << 2 << endl;
    else
    {
        transform(a.begin(), a.end(), a.begin(), ::toupper);
        transform(b.begin(), b.end(), b.begin(), ::toupper);
        if (a == b)
            cout << 3 << endl;
        else
            cout << 4 << endl;
    }
    return 0;
}
2020-01-01 22:28:42
  • «
  • 1
  • »