結果

問題 No.9011 数字を全て足そう(数字だけ)
ユーザー tagufartv
提出日時 2020-09-28 22:19:57
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 214 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 72 ms
コンパイル使用メモリ 31,912 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:22:02
合計ジャッジ時間 654 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:11: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
    7 |     int l=strlen(s);
      |           ^~~~~~
main.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
    2 | #include<stdlib.h>
  +++ |+#include <string.h>
    3 | 
main.c:7:11: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
    7 |     int l=strlen(s);
      |           ^~~~~~
main.c:7:11: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%s",s);
      |     ^~~~~~~~~~~~~

ソースコード

diff #
raw source code

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

int main(void){
    char s[101];
    scanf("%s",s);
    int l=strlen(s);
    int c=0;
    for(int i=0;i<l;i++){
        c+=s[i]-'0';
    }
    printf("%d\n",c);
    return 0;
}
0