Run ID:26818

提交时间:2022-05-24 17:03:45

#include <iostream> #include <cstdlib> #include <cstring> using namespace std; int main() { int i,n=0,num,j; char str[200]; char c; while((c = getchar())!=EOF) { if(c>='A'&&c<='Z') c = c+32; n = 0; memset(str,0,sizeof(str)); cin >>str; num = strlen(str); for(j=0;j<num;j++) { if(str[j]>='A'&&str[j]<='Z') str[j] = str[j]+32; } for(j=0;j<num;j++) { if(str[j] == c) n++; } printf("%.5lf\n",n*1.0/num); getchar();//读取换行 } return 0; }