Skip to content

Instantly share code, notes, and snippets.

@kei9327
Created June 5, 2019 02:40
Show Gist options
  • Save kei9327/b692b455473dc4ecd5cb38154631145a to your computer and use it in GitHub Desktop.
Save kei9327/b692b455473dc4ecd5cb38154631145a to your computer and use it in GitHub Desktop.
HackerRank>Algorithms>Warmup>Staircase
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
// Complete the staircase function below.
void staircase(int n) {
for (int i=0; i < n; i++) {
for (int j=0; j < n-i-1; j++) printf(" ");
for (int k=0; k < i+1; k++) printf("#");
printf("\n");
}
}
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