Run ID:113260

提交时间:2025-03-15 15:58:08

#include <iostream> #include <string> #include <cctype> #include <iomanip> using namespace std; int main() { string input; while (getline(cin, input)) { if (input.empty()) break; char letter = tolower(input[0]); string word = input.substr(2); transform(word.begin(), word.end(), word.begin(), ::tolower); int count = 0; for (char c : word) { if (c == letter) { count++; } } double probability = static_cast<double>(count) / word.length(); cout << fixed << setprecision(5) << probability << endl; } return 0; }