墨香年少 32 发布于 2023年1月13日 #include <iostream> #include <string> #include <algorithm> bool is_numeric(std::string const &str) { auto it = std::find_if(str.begin(), str.end(), [](char const &c) { return !std::isdigit(c); }); return !str.empty() && it == str.end(); } int main() { std::string str = "1234567890"; std::cout << std::boolalpha << is_numeric(str) << std::endl; // true return 0; } 1 目之所及,皆是回忆,心之所想,皆是过往 分享这篇帖子 链接帖子 分享到其他站点