您好,整了好一会儿发现用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