티스토리 뷰
문제 링크
https://www.acmicpc.net/problem/2522
2522번: 별 찍기 - 12
첫째 줄부터 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=i;j<n;j++){ | |
cout << " "; | |
} | |
for(int k=n-i;k<n;k++){ | |
cout << "*"; | |
} | |
cout << endl; | |
} | |
for(int i=1;i<n;i++){ | |
for(int j=0;j<i;j++){ | |
cout << " "; | |
} | |
for(int k=1;k<=n-i;k++){ | |
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(' '* (n-i), end='') | |
print('*'* i) | |
for i in range(1,n): | |
print(' '*i, end='') | |
print('*'*(n-i)) |
'Coding Test > 백준' 카테고리의 다른 글
[C++/Python] 백준 2556 - 별찍기 - 14 (0) | 2020.07.08 |
---|---|
[C++/Python] 백준 2523 - 별찍기 - 13 (0) | 2020.07.07 |
[C++/Python] 백준 2448 - 별찍기 - 11 (0) | 2020.07.05 |
[C++/Python] 백준 2447 - 별찍기 - 10 (0) | 2020.07.04 |
[C++/Python] 백준 2446 - 별찍기 - 9 (0) | 2020.07.03 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 두니발 박사의 탈옥
- 삼각형 위의 최대 경로
- 합친 lis
- 출전 순서 정하기
- 하둡
- Django
- Sqoop
- 스파크
- 팰린드롬 구하기
- 분할정복
- python
- 백준
- 코딩인터뷰 완전분석
- microwaving lunch boxes
- HDFS
- hive
- C++
- 종만북
- 2225
- pyspark
- 알고스팟
- 하이브
- 완전탐색
- Hadoop
- import
- Jaeha's Safe
- HiveQL
- 배열과 문자열
- 외발 뛰기
- 삼각형 위의 최대 경로 수 세기
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함