64,637
社区成员
发帖
与我相关
我的任务
分享
#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;
}
#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;
if (x == s1) break;//加
}
else if (str3[i] == str2[y])
{
y++;
bl = true;
if (y == s2) break;//加
}
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;
}