Again, thisdepends on what is “char”. Let’s assume it as ASCII.char firstSingle(char * str) { int a[255]; memset(a, 0, 255*sizeof(int)); char *p=str; while (*p!=’\0’) { a[*p] ++; p++; } p = str; while (*p!=’\0’) { if (a[*p] == 1) return *p; } return ‘\0’; // this must the one thatoccurs exact 1 time.}
共 1 个关于本帖的回复 最后回复于 2013-8-16 11:11