题解 | #字符个数统计#

字符个数统计

https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50

#include <stdio.h>
#include <string.h>

int main()
{
    char ch[501] = {0};
    scanf("%s",ch);
    int tmp[128] = {0};
    int str = strlen(ch);
    int i = 0;
    int asc = 0;
    int num = 0;
    for(i = 0;i<str;i++)
    {
        asc = (int)ch[i];
        if(tmp[asc]==0)
        {
            tmp[asc] = 1;
            num++;
        }
    }
    printf("%d",num);
    return 0;
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务