/******************************
作者:cncoderalex
博客:http://blog.youkuaiyun.com/cncoderalex
*******************************/
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
using namespace std;
bool fun(string str1, string str2)
{
sort(str1.begin(), str1.end());
sort(str2.begin(), str2.end());
for (int i = 0, j = 0; i < str1.length() && j < str2.length();)
{
while (i < str1.length() && str1[i] < str2[j])
i++;
if (i < str1.length() && str1[i] == str2[j])
{
j++;
continue;
}
return false;
}
return true;
}
int main()
{
printf("http://blog.youkuaiyun.com/cncoderalex");
printf("\n");
bool bRet = false;
bRet = fun("abc", "c");
cout << bRet << endl;
bRet = fun("abc", "cb");
cout << bRet << endl;
bRet = fun("abc", "cba");
cout << bRet << endl;
bRet = fun("asdfg", "gf");
cout << bRet << endl;
bRet = fun("asdfg", "gda");
cout << bRet << endl;
bRet = fun("asdfg", "gdl");
cout << bRet << endl;
system("pause");
return 0;
}