- /*
- //Function:Find the first character which appears only one time in a string
- //Input: the string
- //Output:the character
- */
- char FindFirstChar(char * str) {
- if(str == NULL)
- return 0;
- const int size = 256;
- int hashtable[size];
- for(int i=0; i<size; i++)
- hashtable[i] = 0;
- char * ch = str;
- while(ch != '\0') {
- hashtable[*(ch++)]++;
- }
- char * result = str;
- while(result != '\0') {
- if(hashtable[*result] == 1)
- return *result
- result++;
- }
- return 0;
- }