华为笔试:字符去重
#include <iostream>
#include <vector>
#include<string>
using namespace std;
int main()
{
string s;
string sNew;
int k=0;
cin>>s;
cout<<s[0]<<endl;
cout<<s[1]<<endl;
int len = s.size();
sNew.push_back(s[0]);
for(int i=1;i<len;i++){
int signal = 0;
for(int j=0;j<sNew.size();j++){
char a = sNew[j];
char b = s[i];
if(a == b){
signal = 1;
break;
}
}
if(signal == 0){
sNew.push_back(s[i]);
}
}
for(int m=0;m<sNew.size();m++){
cout<<sNew[m]<<" ";
}
system("pause");
return 0;
}