結果

問題 No.289 数字を全て足そう
ユーザー hape8810
提出日時 2018-12-21 20:28:17
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 251 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 22,272 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-25 09:35:41
合計ジャッジ時間 875 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%s",S);
      |     ~~~~~^~~~~~~~

ソースコード

diff #

#include <stdio.h>
int main(void){
    char S[10000];
    int i,sum=0;
    scanf("%s",S);
    for(i=0;S[i]!='\0';i++){
        if(S[i]>='1' && S[i]<='9'){
            sum= sum+(S[i]-'1'+1);
        }
    }
    
    printf("%d\n",sum);
    return 0;
}
0