結果
| 問題 | 
                            No.289 数字を全て足そう
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-03-31 21:02:55 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 282 bytes | 
| コンパイル時間 | 105 ms | 
| コンパイル使用メモリ | 28,672 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-22 10:15:57 | 
| 合計ジャッジ時間 | 4,554 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 3 | 
| other | RE * 21 | 
コンパイルメッセージ
main.c: In function 'main':
main.c:11:17: warning: passing argument 1 of 'atoi' makes pointer from integer without a cast [-Wint-conversion]
   11 |         r=atoi(i[l]);
      |                ~^~~
      |                 |
      |                 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))
      | ^~~~~
            
            ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
    char i[10000];
    long a=0;
    short int r=0;
    scanf("%s",i);
    for(int l=0; l<=strlen(i); l++) {
        r=atoi(i[l]);
        if(r!=0) {
            a+=r;
        }
    }
    printf("%d",r);
}