結果

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