酷代码 AI
菜单
服务商

C++ 数字字符乘积转换为字符的简洁实现

```cpp #include <iostream> #include <string> int main() { int n; std::cin >> n; std::cin.ignore(); std::string input; std::getline(std::cin, input); if (input.length() != n) { return 1; } int product = 1; bool hasDigit = false; for (char c : input) { if (std::isdigit(c)) { hasDigit = true; product *= (c - '0'); } } if (!hasDigit) { std::cout << "No digits found." << std::endl; } else { std::cout << static_cast<char>(product) << std::endl; } return 0; } ``` ######[AI问答 | 186点数解答 | 2026-05-29 21:06:11]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]