remove duplicated chars in a string
2013-08-14 15:42
148 查看
#include<stdlib.h> char str[7] = {'a','a','a','b','d','a','\0'}; int isExisted[128]; void removeDuplicate(char* input){ char* p = input; char* q = input; while(*q !='\0'){ if(isExisted[(int)*q ] == 0){ isExisted[(int)*q ] = 1; *p++ = *q++; }else{ q++; } } *p = '\0'; } int main(){ removeDuplicate(str); printf("%s",str); getchar(); }
相关文章推荐
- How to remove the duplicated value in a String array
- How do you remove the duplicate characters in a given string without using any additional buffer.
- char * strtrim(char* s ) to remove any space character(such as '\t' , ' ' ...) in a string
- remove duplicated value in an array
- How to remove null value in json string
- how to remove nil and blank string in an array in Ruby
- [CrackCode] 1.3 Remove the duplicate characters in a string
- 【3】Remove the duplicate characters in a string
- [LeetCode] 在矩阵中查找字符串 Search a string in a matrix of chars
- Shifting chars in string
- Return if string t contains all chars in s
- CH1-3: remove duplicate char in a string, with/without additional buffer
- php 怎样去掉一个string 后面的一个或多个字符(how to remove the last n chars from a string)?
- 代码面试题:Delete duplicated char in string
- First Unique Character in a String
- [leetcode, python] Reverse Words in a String 反转字符串
- Store Connection String in Web.config
- leetcode-java-151. Reverse Words in a String
- php insert variable or function in a string
- Leetcode 434 Number of Segments in a String