結果

問題 No.116 門松列(1)
ユーザー くれちー
提出日時 2016-09-29 00:42:45
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 424 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 01:24:15
合計ジャッジ時間 1,080 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:13:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:15:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d", &a[i]);
      |                 ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int iskado(int a, int b, int c) {
	if (a > b && b > c) return -1;
	else if (a < b && b < c) return -1;
	else if (a == b || b == c || c == a) return -1;
	else return 1;
}

int main() {
	int n, a[100], cnt = 0, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = 0; i < n - 2; i++) {
		if (iskado(a[i], a[i + 1], a[i + 2]) == 1) cnt++;
	}

	printf("%d\n", cnt);
	return 0;
}
0