結果

問題 No.289 数字を全て足そう
ユーザー kazuki232
提出日時 2017-02-04 01:27:53
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 206 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 20,864 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 06:06:35
合計ジャッジ時間 796 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:9: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[10000]’ [-Wformat=]
    5 | scanf("%s",&bun);
      |        ~^  ~~~~
      |         |  |
      |         |  char (*)[10000]
      |         char *
main.c:8:4: warning: implicit declaration of function ‘abs’ [-Wimplicit-function-declaration]
    8 | if(abs(bun[i[0]]-53)<=4){i[1]+=(bun[i[0]]-48);}
      |    ^~~
main.c:2:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘abs’
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | int main(){
main.c:5:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 | scanf("%s",&bun);
      | ^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
int main(){
int i[2];
char bun[10000];
scanf("%s",&bun);
i[0]=0;i[1]=0;
while(bun[i[0]]!='\0'){
if(abs(bun[i[0]]-53)<=4){i[1]+=(bun[i[0]]-48);}
i[0]++;
}
printf("%d\n",i[1]);
	return 0;
}
0