题目:删除一个字符串中的指定字母,如:字符串 "aca",删除其中的 a 字母。
程序分析:无。
实例:
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 // 删除字符串中指定字母函数 6 char* deleteCharacters(char * str, char * charSet) 7 { 8 int hash [256]; 9 if(NULL == charSet) 10 return str; 11 for(int i = 0; i < 256; i++) 12 hash[i] = 0; 13 for(int i = 0; i < strlen(charSet); i++) 14 hash[charSet[i]] = 1; 15 int currentIndex = 0; 16 for(int i = 0; i < strlen(str); i++) 17 { 18 if(!hash[str[i]]) 19 str[currentIndex++] = str[i]; 20 } 21 str[currentIndex] = '