티스토리 뷰
문제 링크
https://www.acmicpc.net/problem/2445
2445번: 별 찍기 - 8
첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.
www.acmicpc.net
구현 코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(){ | |
int n; | |
cin >> n; | |
for(int i=1;i<=n;i++){ | |
for(int j=n-i;j<n;j++){ | |
cout << "*"; | |
} | |
for(int k=1;k<=n*2-i*2;k++){ | |
cout << " "; | |
} | |
for(int l=n-i;l<n;l++){ | |
cout << "*"; | |
} | |
cout << endl; | |
} | |
for(int i=1;i<n;i++){ | |
for(int j=i;j<n;j++){ | |
cout << "*"; | |
} | |
for(int k=1;k<=i*2;k++){ | |
cout << " "; | |
} | |
for(int l=i;l<n;l++){ | |
cout << "*"; | |
} | |
cout << endl; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
for i in range(1,n+1): | |
print('*'*(i), end='') | |
print(' ' * ((n*2)-(i*2)), end='') | |
print('*' * (i)) | |
for i in range(1,n): | |
print('*'*(n-i), end='') | |
print(' ' * (i*2), end='') | |
print('*' *(n-i)) |
'Coding Test > 백준' 카테고리의 다른 글
[C++/Python] 백준 2447 - 별찍기 - 10 (0) | 2020.07.04 |
---|---|
[C++/Python] 백준 2446 - 별찍기 - 9 (0) | 2020.07.03 |
[C++/Python] 백준 2444 - 별 찍기 - 7 (0) | 2020.01.28 |
[C++/Python] 백준 2443 - 별 찍기 - 6 (0) | 2020.01.27 |
[C++/Python] 백준 2442 - 별 찍기 - 5 (0) | 2020.01.26 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- HDFS
- 합친 lis
- 스파크
- Hadoop
- 코딩인터뷰 완전분석
- 2225
- 종만북
- Sqoop
- 삼각형 위의 최대 경로 수 세기
- 배열과 문자열
- 하둡
- python
- 팰린드롬 구하기
- 삼각형 위의 최대 경로
- 출전 순서 정하기
- Jaeha's Safe
- 외발 뛰기
- pyspark
- hive
- 완전탐색
- 두니발 박사의 탈옥
- microwaving lunch boxes
- 백준
- HiveQL
- 분할정복
- 알고스팟
- C++
- Django
- import
- 하이브
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
글 보관함