HackerRank Staircase Probelm Solution in C
#include<stdio.h> main() { int i,j,k; int n; scanf("%d",&n); for(i=n-1,j=1;i>=0,j<=n;i--,j++) { for(k=0;k<i;k++) printf(" "); for(k=0;k<j;k++) printf("#"); printf("\n"); } }
HackerRank Staircase Probelm Solution in JavaScript
function processData(input) { //Enter your code here var size = Number(input); for(var i=1; i<=size; i++) { var limit = size-i; var line = ""; for(var j=0; j<size; j++) { if(j < limit) { line += " "; } else { line += "#"; } } console.log(line); } } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
HackerRank Staircase Probelm Solution in Python
t=int(input()) for i in range(t): print(' '*(t-(i+1))+'#'*(i+1))
0 Comments