//No.289 数字を全て足そう #include #include using namespace std; int c_to_i(char _c); int main() { int cnt=0; string S; cin >> S; for (int i = 0; i < S.length(); i++) { cnt += c_to_i(S[i]); } cout << cnt; return 0; } int c_to_i(char _c) { int nt; switch (_c) { case '1': nt = 1; break; case '2': nt = 2; break; case '3': nt = 3; break; case '4': nt = 4; break; case '5': nt = 5; break; case '6': nt = 6; break; case '7': nt = 7; break; case '8': nt = 8; break; case '9': nt = 9; break; default: nt = 0; break; } return nt; }