๐•ƒ๐•ฆ๐•„๐•š๐•ฃ

ใ€ŒโŒจ๏ธแด„sใ€PS/๋ฐฑ์ค€_์ˆ˜ํ•™&๊ตฌํ˜„

[Baekjoon/๋ฐฑ์ค€][2523][C/C++] ๋ณ„ ์ฐ๊ธฐ - 13

by ๋ฃจ๋ฐ€๐•ƒ๐•ฆ๐•„๐•š๐•ฃ2023. 1. 19.
728x90
๋ฐ˜์‘ํ˜•
ใ€Ž๋ชฉ์ฐจใ€
0. ๊ฐœ์š”

1. ๋ฌธ์ œ
2. ํ’€์ด
3. ์ฝ”๋“œ

0. ๊ฐœ์š”

์•ž์„  ํฌ์ŠคํŒ… '๋ณ„์ฐ๊ธฐ - 12'๋ฅผ ๋ณด๊ณ  ์˜ค์ž.

[Baekjoon][2522][C/C++] ๋ณ„ ์ฐ๊ธฐ - 12

1. ๋ฌธ์ œ

https://www.acmicpc.net/problem/2523

 

2523๋ฒˆ: ๋ณ„ ์ฐ๊ธฐ - 13

์ฒซ์งธ ์ค„๋ถ€ํ„ฐ 2×N-1๋ฒˆ์งธ ์ค„๊นŒ์ง€ ์ฐจ๋ก€๋Œ€๋กœ ๋ณ„์„ ์ถœ๋ ฅํ•œ๋‹ค.

www.acmicpc.net

[๋ฌธ์ œ]

์˜ˆ์ œ๋ฅผ ๋ณด๊ณ  ๊ทœ์น™์„ ์œ ์ถ”ํ•œ ๋’ค์— ๋ณ„์„ ์ฐ์–ด ๋ณด์„ธ์š”.

[์ž…๋ ฅ]

์ฒซ์งธ ์ค„์— N(1 ≤ N ≤ 100)์ด ์ฃผ์–ด์ง„๋‹ค.

[์ถœ๋ ฅ]

์ฒซ์งธ ์ค„๋ถ€ํ„ฐ 2×N-1๋ฒˆ์งธ ์ค„๊นŒ์ง€ ์ฐจ๋ก€๋Œ€๋กœ ๋ณ„์„ ์ถœ๋ ฅํ•œ๋‹ค.

[์˜ˆ์ œ ์ž…๋ ฅ 1]

3

[์˜ˆ์ œ ์ถœ๋ ฅ 1]

*
**
***
**
*

2. ํ’€์ด

์•ž์„  '๋ณ„์ฐ๊ธฐ - 12'๋ฌธ์ œ์—์„œ '๊ณต๋ฐฑ ์ฐ๊ธฐ' ๋ถ€๋ถ„์˜ ์ฝ”๋“œ๋งŒ ์—†์• ๋ฉด, ๋ฐ”๋กœ ์•„๋ž˜์ชฝ ์ฝ”๋“œ๊ฐ€ ๋œ๋‹ค.  

์ด๋ฒˆ ๋ฌธ์ œ๋Š” ๋ณ„๋งŒ ์ฐ์œผ๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์—, '๋ณ„์ฐ๊ธฐ - 12' ๋ฌธ์ œ๋ณด๋‹ค ํ›จ์”ฌ ์‰ฝ๋‹ค.

3. ์ฝ”๋“œ

#pragma warning (disable:4996)
#include <stdio.h>

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

	/* ์œ„์ชฝ */
	for (int i = 1; i <= N; i++) {

		/* ๋ณ„ ์ฐ๊ธฐ */
		for (int j = 1; j <= i; j++)
			printf("*");

		/* ๊ฐœํ–‰ */
		printf("\n");
	}

	/* ์•„๋ž˜์ชฝ */
	for (int i = N - 1; i >= 1; i--) {

		/* ๋ณ„ ์ฐ๊ธฐ */
		for (int j = 1; j <= i; j++)
			printf("*");

		/* ๊ฐœํ–‰ */
		printf("\n");
	}

	return 0;
}
728x90
๋ฐ˜์‘ํ˜•