結果

問題 No.289 数字を全て足そう
ユーザー toto
提出日時 2025-03-26 16:59:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 251 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-26 16:59:25
合計ジャッジ時間 1,317 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%s",str);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int main(){
	char str[10000];
	scanf("%s",str);
	
	int len = strlen(str);
	
	int sum = 0;
	for(int i = 0;i < len;i ++){
		if(str[i] >= '1' && str[i] <= '9'){
			sum += (str[i] - '0');
		}
	}
	printf("%d",sum);
}
0