#include #include #include #define READ_BUFSIZE ( 10000 + 1 ) #define READ_DELIMITER ( " " ) //標準入力取得(1行) int GetStdin( char* pszStr, int lMaxLen ) { int lLen = 0; memset( pszStr, 0, lMaxLen ); if( fgets( pszStr, lMaxLen, stdin ) ) { lLen = strlen( pszStr ); if( lLen >= 1 ) { if( pszStr[ lLen - 1 ] == 0x0A ) { pszStr[ lLen - 1 ] = 0; lLen--; } } } return( lLen ); } int main(int argc, char *argv[]) { char szRead[READ_BUFSIZE] = ""; //char* psOutbuf[2] = { 0 }; GetStdin( szRead, READ_BUFSIZE ); int lSummary = 0; for( int i = 0; szRead[i] != 0; i++ ) { //数字の範囲 0x30 ー 0x39 if( szRead[i] >= '0' && szRead[i] <= '9' ) lSummary += (int)( szRead[i]-'0' ); } printf( "%d\n", lSummary ); return 0; }