[恢]hdu 2131
2011-12-16 06:45:55
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2131
题意:问给的字母在后面单词中出现的比例是多少。注意不区分大小写。
代码:
# include <stdio.h>
char word[210] ;
int main ()
{
char ch ;
int i, sum ;
while (~scanf ("%c %s%*c", &ch, word))
{
sum = 0 ;
for (i = 0 ; word[i] ; i++)
if ((word[i] | 0x20) == (ch | 0x20)) sum++ ;
printf ("%.5lf\n", 1.0*sum/i) ;
}
return 0 ;
}