We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  • Hiring developers?
  1. Practice
  2. Algorithms
  3. Warmup
  4. Staircase
  5. Discussions

Staircase

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

    You are viewing a single comment's thread. Return to all comments →

  • Mr_Squid 4 years ago+ 1 comment

    I did this:

    import java.io.*;
    import java.util.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
    
            for (int i = 1; i <= n; i = i + 1) {
                int pt = n - i;
                for (int c = 1; c <= pt; c = c + 1) {
                    System.out.print(" ");
                }
                for (int c = 1; c <= i; c = c + 1) {
                    System.out.print("#");
                }
                if (i < n) {
                    System.out.println();
                }
            }
        }
    }
    
    4|
    ParentPermalink
    • 88jayto 4 years ago+ 2 comments

      mine was pretty similar

      public static void main(String[] args) {
          Scanner in = new Scanner(System.in);
          int n = in.nextInt();
          drawStairCase(n);
      }
      
      static void drawStairCase(int height){
          for(int i = 0; i<height; i++){
              for(int x = i+1; x < height; x++){
                  System.out.print(" ");
              }
              for(int x = height-(i+1); x < height; x++){
                  System.out.print("#");
              }
              System.out.println();
          }
      }
      
      6|
      ParentPermalink
      • CyberMew 4 years ago+ 0 comments

        in.close();

        4|
        ParentPermalink
      • vigneshwar028 2 years ago+ 0 comments

        can you explain your code ?

        0|
        ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature