标签:
1 /************************************************************************* 2 > File Name: 33_FirstNotRepeatChar.c 3 > Author: Juntaran 4 > Mail: JuntaranMail@gmail.com 5 > Created Time: 2016年09月02日 星期五 13时43分20秒 6 ************************************************************************/ 7 8 #include <stdio.h> 9 10 char FirstNotRepeatChar(char* str) 11 { 12 if (str == NULL) 13 return ‘\0‘; 14 int HashSize = 256; 15 int hash[HashSize] = {0}; 16 17 char* key = str; 18 while (*key != ‘\0‘) 19 { 20 printf("*key = %d\n", *key); 21 hash[*key] ++; 22 *key ++; 23 } 24 25 key = str; 26 while (*key != ‘\0‘) 27 { 28 printf("%d ", hash[*key]); 29 if (hash[*key] == 1) 30 return *key; 31 key ++; 32 } 33 return ‘\0‘; 34 } 35 36 int main() 37 { 38 char str[] = "adaccbweff"; 39 char ret = FirstNotRepeatChar(str); 40 printf("%c\n", ret); 41 }
标签:
原文地址:http://www.cnblogs.com/Juntaran/p/5835667.html