{"title":"判断用户名性别:奇数字符男,偶数字符女 - C++ 代码实现", "description":"本程序通过分析用户名的字符个数奇偶性来判断性别,奇数字符为男生,偶数字符为女生,使用 C++ 语言实现。", "keywords":"用户名性别判断, 字符奇偶性, C++ 代码, 字符串处理, 编程练习", "content":"#include \n#include \n#include <unordered_set>\n\nusing namespace std;\n\nint main() {\n string username;\n cin >> username;\n\n unordered_set distinctChars;\n\n for (char c : username) {\n distinctChars.insert(c);\n }\n\n if (distinctChars.size() % 2 == 0) {\n cout << "Girl" << endl;\n } else {\n cout << "Boy" << endl;\n }\n\n return 0;\n}"}


原文地址: https://www.cveoy.top/t/topic/pQJG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录