题解 | #字符个数统计#

字符个数统计

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;
}
全部评论

相关推荐

合不合适,我自己说了才算
码农索隆:hr:“真执着啊,来我公司当法人吧”
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-09 13:05
TMD找工作本来就烦,这东西什么素质啊😡
Beeee0927:hr是超雄了,不过也是有道理的
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务