結果

問題 No.987 N×Mマス計算(基本)
ユーザー sasa
提出日時 2025-03-18 09:39:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 27,776 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-18 09:39:52
合計ジャッジ時間 1,371 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d%d",&tate,&yoko);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%s",symbol);
      |         ~~~~~^~~~~~~~~~~~~
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 scanf("%ld",&horizontal[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%ld",&vertical[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
int main(void){
	// 縦・横の長さ
	int tate,yoko;
	scanf("%d%d",&tate,&yoko);
	// 計算記号
	char symbol[1];
	scanf("%s",symbol);
	// 各数値
	long vertical[tate],horizontal[yoko];
	for(int i = 0;i < yoko;i ++){
		scanf("%ld",&horizontal[i]);
	}
	for(int i = 0;i < tate;i ++){
		scanf("%ld",&vertical[i]);
		for(int j = 0;j < yoko;j ++){
			if(symbol[0] == '*'){
				printf("%ld ",vertical[i] * horizontal[j]);
			}else if(symbol[0] == '+'){
				printf("%ld ",vertical[i] + horizontal[j]);
			}
		}
		printf("\n");
	}
	
	
}
0