可以定义一个数组a,然后a(I)=string(I)-'0'这样就得到这个数的每位数,然后求解
#include bool convert(const std::string& s, int& x){ std::stringstream istr(s); if (!(istr >> x)) return false; return true;}