Run ID:158654
提交时间:2026-08-22 16:21:50
#include <iostream> #include <string> #include <iomanip> #include <cctype> using namespace std; int main() { char ch; string word; // 多组输入,直到读完 while (cin >> ch >> word) { char target = tolower(ch); int cnt = 0; int len = word.size(); for (char c : word) { if (tolower(c) == target) cnt++; } double prob = 1.0 * cnt / len; // 保留5位小数输出 cout << fixed << setprecision(5) << prob << endl; } return 0; }