-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsameStringFilter.cpp
More file actions
29 lines (27 loc) · 854 Bytes
/
sameStringFilter.cpp
File metadata and controls
29 lines (27 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/******************************************
*@file: sameStringFilter.cpp
*@author: Hu Pan
*@date: 2015/09/12
*@version: 0.1
*@describe: 清除字符串中非第一次出现的字符
******************************************/
#include "tools.h"
#include <cctype>
void sameStringFilter(const char *pInputStr, long lInputLen, char *pOutputStr)
{
int charNumCount[26];
memset(charNumCount, 0, sizeof(int)* 26);
long j = 0;
for (long i = 0; i != lInputLen; ++i)
{
++charNumCount[pInputStr[i] - 'a'];
if (islower(pInputStr[i]) && 1 == charNumCount[pInputStr[i] - 'a'])
{
pOutputStr[j++] = pInputStr[i];
}
}
pOutputStr[j] = '\0';
//display(pInputStr, pInputStr + lInputLen);
//display(charNumCount, charNumCount + 26);
//display(pOutputStr, pOutputStr + lInputLen);
}