結果

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

ソースコード

diff #

#include <stdio.h>

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