結果

問題 No.135 とりあえず1次元の問題
ユーザー mosmos_21
提出日時 2016-10-14 18:15:00
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 307 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 21,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 07:01:08
合計ジャッジ時間 1,043 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |   scanf("%d", &n);
      |   ^~~~~~~~~~~~~~~
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   if(n) scanf("%d", &a);
      |         ^~~~~~~~~~~~~~~
main.c:9:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%d", &b);
      |     ^~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
int main(){
  int i, n, a, b, c = 10000000;
  scanf("%d", &n);

  if(n) scanf("%d", &a);
  for(i = 1; i < n; i++){
    scanf("%d", &b);
    if(a != b && abs(a - b) < c)
      c = abs(a - b);
    a = b;
  }
  if(c == 10000000) c = 0;
  printf("%d\n", c);
  return 0;
}
0