#include #include #include class sumNumber { private: int m_sum; std::string m_iData; public: sumNumber() : m_sum(0), m_iData("") {}; void read(); void sum(); void show(); }; void sumNumber::read() { std::cin >> m_iData; } void sumNumber::sum() { for (int i = 0; i < m_iData.size(); ++i) { int tNum = m_iData[i] - 0x30; if (0 > tNum && 9 < tNum) { continue; } m_sum += tNum; } } void sumNumber::show() { std::cout << m_sum << std::endl; } int main() { sumNumber obj; obj.read(); obj.sum(); obj.show(); }