Home > Back-end >  JAVA HASHMAP into the C language
JAVA HASHMAP into the C language

Time:09-25

Public static char [] killRepeat (String s) {
String ss="";
HashSet The hs=new HashSet (a);
for (int i=0; i The hs. The add (s.c harAt (I) + "");
}
For (String nt: hs) {
Ss +=nt;
}
Return ss. ToCharArray ();
}
How do you write the code above, translated into c + +??????? Be urgent!!!!!!

CodePudding user response:

 # include & lt; Hash_set & gt; 
#include

Using STD: : hash_set;
Using STD: : string;

Const char * killRepeat (string inputString)
{
Size_t strlen=inputString. Length ();
Char * result=new char strlen (+ 1);
Memset (result, 0, strlen + 1);

Hash_set & lt; Char> CharList;
For (size_t I=0; i CharList. Insert (inputString [I]);

Hash_set & lt; Char> : : iterator it=charList. The begin ();

Char * pchar=the result;

for (; it !=charList. End (); It++)
* pchar=* it pchar++;

return result;
}
  • Related