結果

問題 No.289 数字を全て足そう
ユーザー pracode
提出日時 2018-09-16 20:48:29
言語 C
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 235 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 28,288 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-18 07:31:21
合計ジャッジ時間 3,733 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:13:22: warning: passing argument 1 of 'atoi' makes pointer from integer without a cast [-Wint-conversion]
   13 |         sum+=atoi(str[i]);
      |                   ~~~^~~
      |                      |
      |                      char
In file included from /usr/include/features.h:486,
                 from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from main.c:1:
/usr/include/stdlib.h:362:1: note: expected 'const char *' but argument is of type 'char'
  362 | __NTH (atoi (const char *__nptr))
      | ^~~~~

ソースコード

diff #

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

int main()
{
    char str[100001];
    int i;
    int sum=0;
    
    scanf("%s",str);
    
    for(i=0;str[i]!='\0';i++){
        sum+=atoi(str[i]);
    }
    printf("%d\n",sum);
    return 0;
}
0