Find no identical characters (ZT) - very clever! ! !

xiaoxiao2021-03-06  17

Write a function fn (), the function is to pass a parameter is a string. There is no identical character in the lookup. If you return 1, otherwise it will be the highest, the second is the most cost-saving.

INT fn0 (const char * str) {char NUM [256] = {0}; unsigned char * pOS = (unsigned char *) str; while (* pos! = 0 && num [* pos] == 0) {Num [* POS ] = 1;} return * pOS == 0? 0: 1;} int FN1 (const char * STR) {const char * p1, * p2; if (* str == 0) Return 0; for P1 = STR; * P1! = 0; P1 ) {for (p2 = p1 1; * p2! = 0; p2 ) {IF (* p1 == * p2) Return 1;}} return 0;}

转载请注明原文地址:https://www.9cbs.com/read-45993.html

New Post(0)