Skip to content

Instantly share code, notes, and snippets.

@codeperfectplus
Created September 16, 2023 06:22
Show Gist options
  • Save codeperfectplus/fda9437fb537ec5c011b09265a69d1cb to your computer and use it in GitHub Desktop.
Save codeperfectplus/fda9437fb537ec5c011b09265a69d1cb to your computer and use it in GitHub Desktop.
/*
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