Skip to content

Instantly share code, notes, and snippets.

@husnain-iqbal
Created February 15, 2016 16:27
Show Gist options
  • Select an option

  • Save husnain-iqbal/3a146841cc80b98ed43b to your computer and use it in GitHub Desktop.

Select an option

Save husnain-iqbal/3a146841cc80b98ed43b to your computer and use it in GitHub Desktop.
Your teacher has given you the task of drawing a staircase structure. Being an expert programmer, you decided to make a program to draw it for you instead. Given the required height, can you print a staircase as shown in the example? Input You are given an integer NN depicting the height of the staircase. Output Print a staircase of height NN th…
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for(int i=0; i<n; i++){
String printStr = "";
for(int j=0; j<=i; j++){
printStr += "#";
}
System.out.println(String.format("%"+n+"s", printStr));
}
}
}
@windbreak22
Copy link

In my opinion, everything has already been described here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment