题解 | #字符个数统计#
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
#include <stdio.h> #include <string.h> int main() { char a[500]; int len; int ch[128] = {0}; int count = 0; scanf("%s", &a); char*p = a; len = strlen(a); for(int i = 0;i < len;i++){ if(ch[*p] == 0){ ++count; ch[*p] = 1; } ++p; } printf("%d", count); return 0; }
如果能想办法解决strlen 这一步就好了,性能有点低