結果

問題 No.998 Four Integers
ユーザー Maeda
提出日時 2025-03-18 17:38:50
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 511 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 25,728 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-18 17:38:52
合計ジャッジ時間 1,280 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 scanf("%d",&numList[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int compareIntegers(const void *a, const void *b) {
    return (*(int*)a - *(int*)b);
}


void main(void){
	int numList[4] = {0,0,0,0};
	for(int i = 0; i < 4 ; i++){
		scanf("%d",&numList[i]);
	}
	size_t arraySize = sizeof(numList) / sizeof(numList[0]);
	qsort(numList, arraySize, sizeof(int), compareIntegers);

	if(numList[0]+1 == numList[1] && numList[1]+1 == numList[2] && numList[2]+1 == numList[3]){
		printf("Yes");
	}else{
		printf("No");
	}
}
0