Created
September 16, 2023 06:22
-
-
Save codeperfectplus/fda9437fb537ec5c011b09265a69d1cb to your computer and use it in GitHub Desktop.
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
/* | |
Topic : Algorithms | |
Subtopic : StairCase | |
Language : C++ | |
Problem Statement : Write a program that prints a staircase of size 'n'. | |
Url : https://www.hackerrank.com/challenges/staircase/problem | |
*/ | |
#include <bits/stdc++.h> | |
using namespace std; | |
// Complete the staircase function below. | |
void staircase(int n) { | |
for(int i=0;i<n;i++) { | |
cout << setfill(' ') << setw(n-(i+1)) << ""; | |
cout << setfill('#') << setw(i+1) << '#'<< endl; | |
} | |
} | |
int main() | |
{ | |
int n; | |
cin >> n; | |
cin.ignore(numeric_limits<streamsize>::max(), '\n'); | |
staircase(n); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment