結果
| 問題 |
No.289 数字を全て足そう
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-29 23:54:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 844 bytes |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 24,832 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 15:11:52 |
| 合計ジャッジ時間 | 920 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
}