티스토리 뷰
문제 링크
https://www.acmicpc.net/problem/10992
10992번: 별 찍기 - 17
예제를 보고 규칙을 유추한 뒤에 별을 찍어 보세요.
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> | |
#define endl '\n' | |
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr) | |
using namespace std; | |
int main(){ | |
fastio; | |
int n; | |
cin >> n; | |
for(int i=0;i<n-1;i++){ | |
for(int j=i;j<n-1;j++){ | |
cout << ' '; | |
} | |
cout << '*'; | |
if(i==0){ | |
cout << endl; | |
continue; | |
} | |
for(int k=0;k<i*2-1;k++){ | |
cout << ' '; | |
} | |
cout << '*' << endl; | |
} | |
for(int i=0;i<n*2-1;i++){ | |
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(n-1): | |
print(' ' * (n-i-1), end='') | |
print('*', end='') | |
if i==0: | |
print() | |
continue | |
print(' ' * (i*2-1), end='') | |
print('*') | |
print('*'*(n*2-1)) |
'Coding Test > 백준' 카테고리의 다른 글
[C++/Python] 백준 10994 - 별찍기 - 19 (0) | 2020.07.13 |
---|---|
[C++/Python] 백준 10993 - 별찍기 - 18 (0) | 2020.07.12 |
[C++/Python] 백준 10991 - 별찍기 - 16 (0) | 2020.07.10 |
[C++/Python] 백준 10990 - 별찍기 - 15 (0) | 2020.07.09 |
[C++/Python] 백준 2556 - 별찍기 - 14 (0) | 2020.07.08 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- HiveQL
- Sqoop
- 완전탐색
- python
- 팰린드롬 구하기
- 스파크
- Django
- 배열과 문자열
- 합친 lis
- Jaeha's Safe
- 출전 순서 정하기
- import
- 외발 뛰기
- hive
- 삼각형 위의 최대 경로 수 세기
- HDFS
- 삼각형 위의 최대 경로
- 백준
- microwaving lunch boxes
- 분할정복
- 두니발 박사의 탈옥
- 알고스팟
- C++
- 종만북
- 코딩인터뷰 완전분석
- 하둡
- Hadoop
- pyspark
- 하이브
- 2225
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함