結果

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

ソースコード

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 tmp = 0;
	if(count % divide == 0){
		tmp = count / divide;
	}else{
		tmp = (count / divide) + 1;
	}
	int val[tmp][divide];
	
	int k = 0;
	for(int i = 0;i < tmp;i++){
		for(int j = 0;j < divide;j++){
			if(k < count){
				scanf("%d",&val[i][j]);
				printf("%d ",val[i][j]);	
			}
			k++;
		}
		printf("\n");
	}
}
0