HDU 2131
来源:互联网 发布:android没有网络展示 编辑:程序博客网 时间:2024/05/18 14:13
Probability
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4653 Accepted Submission(s): 2325
Problem Description
Mickey is interested in probability recently. One day , he played a game which is about probability with mini.First mickey gives a letter and a word to mini.Then mini calculate the probability that the letter appears in the word.For example,give you the letter "a" and the word "apple". the probability of this case is 0.20000.
Input
The input contains several test cases. Each test case consists of a letter and a word.The length of the word is no longer than 200.
Output
For each test case, print the probability rounded to five digits after the decimal point.
Sample Input
a applec Candya banana
Sample Output
0.200000.200000.50000
#include<stdio.h>#include<string.h>#include<ctype.h>int main(){char a[300],c1,c2;int ans,m,cnt;while(scanf("%c %s",&c1,a)!=EOF){cnt=0;m=strlen(a);c1=tolower(c1);ans=c1-'a';for(int i=0;i<m;i++){c2=tolower(a[i]);if(ans==c2-'a') cnt++;}printf("%.5f\n",(double)cnt/m);getchar();}return 0;}
1 0
- hdu 2131
- HDU 2131
- HDU 2131 Probability
- HDU 2131 水
- HDU 2131 Probability
- hdu 2131 Probability
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- Extjs4.1文档example学习之 Array Grid Example
- 对方尽快答复机会
- WorkSpace使用(与Library结合)
- 写点什么
- uva 11520 暴力
- HDU 2131
- Oracle11gr2新增APPEND_VALUES提示
- note_practical_C_programming chapter 10
- php按首字母排序
- 一步一步学习JavaScript
- 中国码农硅谷生存现状调查
- Codeforces Round #247 (Div. 2)
- Eclipse编写和调试Applet程序,调试的时候Eclipse会自动调用Java "小程序查看程序",而不用嵌入到网页中查看运行效果。
- 锤子手机T1发布:售价3000元起 7月初上市