杭电acm2131

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

简单逐个匹配就可以了

View Code
 1 #include<stdio.h>
 2 #include<string.h>
 3 char tw(char a)
 4 {
 5    if(a>='A'&&a<='Z')
 6      return (a+32);
 7    return a;
 8 }
 9 int main()
10 {
11     char a,s[201],b[20];
12     int j;
13     double i,sum;
14     while(scanf("%c %s",&a,s)!=EOF)
15     {
16        gets(b);
17         i=0;
18         sum=strlen(s);
19         for(j=0;s[j]!='\0';j++)
20         if(tw(s[j])==tw(a))
21         i+=1;
22         printf("%.5lf\n",i/sum);
23     }
24     return 0;
25 }

 

posted @ 2013-04-19 20:20  执着追求的IT小小鸟  阅读(237)  评论(0编辑  收藏  举报