結果

問題 No.455 冬の大三角
ユーザー hirakich1048576
提出日時 2016-12-07 22:19:28
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 20,736 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-29 21:22:58
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54
権限があれば一括ダウンロードができます
コンパイルメッセージ
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) {
		s[(x.h + 1) % h][y.w] = '*';
	} else if (x.w == y.w) {
		s[x.h][(y.w + 1) % w] = '*';
	} else{
		s[x.h][y.w] = '*';
	}

	l();

	return 0;
}

0