题解 | #字符个数统计#
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
/*************************** *哈希表真的好用,特别是字符串,省内存 ***************************/ #include <stdio.h> #include <string.h> int main() { char c; char hash[127] = {0}; int count = 0; c = getchar(); while( c != '\n' ) { hash[c]++; if( hash[c] == 1 ) { count++; } c = getchar(); } printf("%d", count); return 0; }