結果

問題 No.21 平均の差
ユーザー sasa
提出日時 2025-02-28 17:28:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 455 ms
コンパイル使用メモリ 29,440 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-28 17:28:38
合計ジャッジ時間 1,287 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d",&count);
      |         ~~~~~^~~~~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d",&divide);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 scanf("%d",&p[i]);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
	// 数値の数
	int count = 0;
	scanf("%d",&count);
	// 振り分ける数
	int divide = 0;
	scanf("%d",&divide);
	// 数値
	int val[count];
	int *p = val;
	for(int i = 0;i < count;i++){
		scanf("%d",&p[i]);
		printf("%d ",p[i]);
	}
	printf("\n");
	// 数値のソート(降順)
	for(int i = 0;i < count;i++){
		for(int j = 0;j < count;j++){
			if (p[i] > p[j])
			{
			    int x = p[j];
			    p[j] = p[i];
			    p[i] = x;
			}
		}
	}
	for(int i = 0;i < count;i++){
		printf("%d ",p[i]);
	}
	int tmp = 0;
	if(count % divide == 0){
		tmp = count / divide;
	}else{
		tmp = (count / divide) + 1;
	}
}
0