#include<iostream>
#include<algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
string str1;
string str2;
cin >> str1 >> str2;
int t = 0;
string bad;
for (int i = 0; i < str1.size(); i++)
{
if (str1[i] == str2[t])
{
t++;
}
else
bad += str1[i];
}
for (int j = 0; j < bad.length(); j++)
cout << bad[j] << " ";
cout << endl;
string zhuanhua;
for (int j = 0; j < bad.length(); j++)
{
char daxie;
if (bad[j] <= 122 && bad[j] >= 97)
{
daxie = bad[j] - 32;
zhuanhua += daxie;
}
else
zhuanhua += bad[j];
}
/*for (int j = 0; j < zhuanhua.length(); j++)
cout << zhuanhua[j] << " ";*/
/*cout << endl;*/
int rr = 0;
bool tag[256] = { false };
int i = 0;
int j = 0;
while (zhuanhua[i] != '\0')
{
if (!tag[zhuanhua[i]])
{
cout << zhuanhua[i];
tag[zhuanhua[i]] = true;
/*zhuanhua[j++] = zhuanhua[i];*/
}
i++;
}
/*zhuanhua[j] = '\0';*/
for (int rr = 0; rr < zhuanhua.length(); rr++)
cout << zhuanhua[rr] << endl;
}
这里解决了:如何在string中删除重复的字符
这里采用的方法是以空间换时间
需要注意的是:string字符串并不是以\0作为结束标志,它仅仅只是个空字符!!