해커랭크(HackerRank)
Staircase
cepiloth
2018. 8. 19. 17:44
반응형
1. 문제
2. 알고리즘
키워드 - 구현, 출력
3. 코드
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 31 32 33 | #include <bits/stdc++.h> using namespace std; /* * Complete the staircase function below. */ void staircase(int n) { /* * Write your code here. */ for(int i =0; i<n; i++) { for(int j =i; j<n-1; j++) { cout << " "; } for(int j =n-i-1; j<n; j++) { cout << "#"; } cout << endl; } } int main() { int n; cin >> n; cin.ignore(numeric_limits<streamsize>::max(), '\n'); staircase(n); return 0; } | cs |
반응형