結果

問題 No.289 数字を全て足そう
ユーザー Maeda
提出日時 2025-03-03 14:38:00
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 372 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 25,344 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-03-03 14:38:02
合計ジャッジ時間 1,661 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

void main(void){
	char str[10000];
    int inputStr =scanf("%s\n",str);
    if(inputStr == 2){
    	printf("文字列の入力ミス\n");
    }
	int sum = 0 , i = 0 ;
	while(str[i] != '\0'){
		int charNum = str[i] - '0';
		if(charNum >= 0 && charNum <= 9){
			sum += charNum;
		}	
		i++;
	}
	printf("%d\n",sum);
}
0