Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
113260 彭士宝 字母概率 C++ Compile Error 0 MS 0 KB 659 2025-03-15 15:58:08

Tests(0/0):


Code:

#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; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:12:68: error: 'transform' was not declared in this scope
         transform(word.begin(), word.end(), word.begin(), ::tolower);
                                                                    ^