交替字符串 不知道哪里出了问题 QAQ

云之_彼端 云之_彼端 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
class HelloWord {
public:
static string getInfo(string str)
{
string str1, str2, str3;
bool bl = false;
cin >> str1;
cin >> str2;
cin >> str3;
int s1 = str1.size(), s2 = str2.size(), s3 = str3.size();
int i = 0, x = 0, y = 0;
if (s1 + s2 == s3 && (s1!=0 || s2!=0))
{
for (; i != s3; i++)
{
if (str3[i] == str1[x])
{
x++;
bl = true;
}
else if (str3[i] == str2[y])
{
y++;
bl = true;
}
else
{
bl = false;
str = "NO";
break;
}
}
if (bl)
{
str = "YES";
}
}
else
{
str = "NO";
}
return str;
}
};
int main()
{
string c = HelloWord::getInfo("Hello World");
cout << c << endl;
}
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
云之_彼端
C++ 语言 65,213 成员 250,513 内容