euisblue
2439. 별 찍기 - 2

2439: 별 찍기 - 2

첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 오른쪽 정렬로 찍는 문제

C++

1#include <bits/stdc++.h> 2using namespace std; 3int main(void) { 4 ios::sync_with_stdio(0); 5 cin.tie(0); 6 int n; cin >> n; 7 8 for(int i=0;i <n; ++i) { 9 for(int j=n; j>i+1; --j) 10 cout << " "; 11 for(int j=0; j<i+1; ++j) 12 cout << "*"; 13 cout << endl; 14 } 15 16 return 0; 17}