标签:
1 #include <stdio.h> 2 3 int charCount(char *str) 4 { 5 int iCount = 0; 6 int i, j, k=0; 7 char *p = str; 8 char *q = p; 9 while (*p) 10 { 11 p++; 12 k++; 13 } 14 for (i=0; i<128; i++) 15 { 16 str = q; 17 for (j=0; j<k; j++) 18 { 19 if (i == *str) 20 { 21 iCount++; 22 break; 23 } 24 str++; 25 } 26 } 27 return iCount; 28 } 29 30 int main() 31 { 32 char *p = " abcdeef121"; 33 printf("%d\n", charCount(p)); 34 return 0; 35 }
实现统计一个字符串所含的不同字符的总数.比较简单,但是这个确实是考验你的基础扎实与否.
标签:
原文地址:http://www.cnblogs.com/qq702368956/p/5055872.html