题解 | #字符个数统计#
字符个数统计
http://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
#include<stdio.h>
#include<string.h>
int main(void)
{
char DataBuff[502];
int dataCompare[128] = {0};
int dataBuffLen = 0;
int count = 0;
fgets(DataBuff, 502, stdin);
dataBuffLen = strlen(DataBuff);
for(int i=0; i<dataBuffLen; i++)
{
if(0 <= DataBuff[i] && 127 >= DataBuff[i])
{
if('\n' != DataBuff[i])
{
dataCompare[DataBuff[i]] = 1;
}
}
}
for(int i=0; i<128; i++)
{
if(1 == dataCompare[i])
{
count++;
}
}
printf("%d",count);
return 0;
}