#include <iostream> #include "OJ.h" using namespace std;/*description given a string, all the characters in the string are deleted, the remaining characters are preserved, and the output The string after the rationale. The order in which characters appear must be guaranteed. Prototype int GetResult (const char *input, char *output) input Param inputs string output Param Output string return Value 0 Success-1 failure and exception */int GetResult (const char *input, char *output) {if (NULL = = Input | | NULL = = output) {return-1; } int *ch = new int [256];//as the character has been marked memset (CH, 0, sizeof (int) *256); int iincur = 0; int ioutcur = 0; while (' input[iincur '! =]) {if (0 = = Ch[input[iincur]]) {Ch[input[iincur]] = 1; Output[ioutcur] = Input[iincur]; ioutcur++; } iincur++; } Output[ioutcur] = ' + '; delete [] ch; return 0;} int main () {char result[1024] = {0}; GetResult ("Abadcbad", result); cout<<result<<endl; return 0;}
Delete duplicate strings