Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
150987 李鸣 字母概率 C++ Accepted 6 MS 276 KB 496 2026-04-02 16:01:27

Tests(1/1):


Code:

#include <iostream> #include <string> #include <cstdio> #include <cctype> using namespace std; int main() { char c; string s; // 多组读取字母+单词 while (cin >> c >> s) { char tar = tolower(c); int cnt = 0; int len = s.size(); for (char ch : s) { if (tolower(ch) == tar) cnt++; } double p = 1.0 * cnt / len; printf("%.5f\n", p); } return 0; }