結果

問題 No.289 数字を全て足そう
ユーザー ReERishun
提出日時 2020-03-27 02:12:23
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 299 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 25,088 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 07:49:07
合計ジャッジ時間 958 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:8:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[10000]’ [-Wformat=]
    8 |     scanf("%s",&input);
      |            ~^  ~~~~~~
      |             |  |
      |             |  char (*)[10000]
      |             char *
main.c:8:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |     scanf("%s",&input);
      |     ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(){
    
    char input[10000];
    int ans = 0;
    
    scanf("%s",&input);
    
    for(int i=0;input[i] != '\0';i++){
        if(input[i] >= '0' && input[i] <= '9')
            ans += ( (int)input[i] - (int)'0' );
    }
    
    printf("%d",ans);
    
    return 0;
}
0