http://acm.hdu.edu.cn/showproblem.php?pid=2131

求字母在单词中出现的概率,无视大小写

View Code
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    char sp,word[210];
    int i,len,cnt; 
    while(~scanf("%c%s%*c",&sp,word))
    {
        len=strlen(word);
        cnt=0;
        for(i=0;i<len;i++)
            if(word[i]==sp||word[i]==sp+32||word[i]==sp-32)
                cnt++;
        printf("%.5lf\n",1.0*cnt/len);
    }
    return 0;
}

 

相关文章:

  • 2021-04-03
  • 2021-12-22
  • 2021-06-16
  • 2021-09-09
  • 2021-07-16
  • 2021-09-18
  • 2022-12-23
  • 2022-03-07
猜你喜欢
  • 2022-01-18
  • 2021-08-11
  • 2021-05-19
  • 2022-02-04
  • 2021-11-10
  • 2021-12-13
  • 2021-04-27
相关资源
相似解决方案