4/02/2017

Hacker Rank solution for Staircase in C++

Problem:- staircase solution in C++ or staircase hacker rank solution in Java or staircase hacker rank solution c++ or staircase hacker rank solution c++ or staircase program in c or staircase solution in c or staircase hacker rank solution in python or staircase in java or staircase hacker rank solution in c or Hacker Rank Solution For staircase in C++ or staircase in C++ or Hacker Rank solution for staircase in C++.


Logic:- staircase hacker rank solution there is no logic we have to just print the pattern in a staircase by using the hash (#) symbol. we always use stairs in our daily life now turn to implement in programming life. See the below pattern this is called a staircase.When asking for the user to enter the number that means the height of staircase. In this case, I am taking Height = 10.

Staircase Pattern

                  #
                ##
              ###
            ####
          #####
        ######
      #######
    ########
  #########
##########

Check- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard Domain.


Submit your solution here:- Click here

Tip:- Before copy the solution I recommended please read this full article, this will help you to build your own logic. 

Solution:-

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,i,j,k;
    cin >> n;

    for(i=n;i>=1;i--)

{
        for(j=1;j<i;j++)
{
            cout<<" ";
        }
        for(k=n;k>=i;k--)
{
            cout<<"#";
        }
        cout<<endl;
    }    

    return 0;
}

Output:-


Hacker Rank solution for Staircase in C++


Hacker Rank solution for Staircase in C++


You May Like This:-

1. Hacker Rank Solution for 30 Days of Code

2. Hacker Rank solution for Attribute Parser

3. Java Program For Find The Gross Salary Of An Employee

4. Hacker Rank Solution For Conditional Statements

5. Hacker Rank Solution For Mini-Max Sum

6. Hacker Rank Solution For Birthday Cake Candles

7. Geeksforgeeks Solution For " Sum of Middle Elements of two sorted arrays "

8. Java Program For Converting Temperature Celsius Into Fahrenheit

9. Geeksforgeeks Solution For " Two Repeated Elements "

10. Hacker Rank Solution For Virtual Functions


1 comment:

  1. I decided to decorate the stairwell with artificial stone, and it paid off. Read More Here

    ReplyDelete