結果

問題 No.455 冬の大三角
ユーザー hirakich1048576
提出日時 2016-12-07 22:11:34
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 672 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 21,120 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-28 03:30:23
合計ジャッジ時間 2,308 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:35:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   35 |         scanf("%d%d", &h, &w);
      |         ^~~~~~~~~~~~~~~~~~~~~
main.c:37:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |         for (i = 0; i < h; i++) scanf("%s", s[i]);
      |                                 ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

typedef struct {int h; int w;} vect;

int i, j, h, w;
char s[100][101];
vect x, y;

void findstars()
{
	x.h = -1;
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
		{
			if (s[i][j]) {
				if (x.h == -1) {
					x.h = i;
					x.w = j;
				} else {
					y.h = i;
					y.w = j;
					return;
				}
			}
		}
}

void l () {
	for (i = 0; i < h; i++) puts(s[i]);
		return;
}

int main(int argc, char const *argv[])
{
	scanf("%d%d", &h, &w);

	for (i = 0; i < h; i++) scanf("%s", s[i]);

	findstars();
	
	if (x.h == y.h) {
		if (x.h) {
			s[x.h - 1][y.w] = '*';
		} else {
			s[x.h + 1][y.w] = '*';
		}
	} else {
		s[x.h][y.w] = '*';
	}

	l();

	return 0;
}

0