consider a staircase of size :
#
##
###
####
Observe that its base and height are both equal to , and the image is drawn using
#
symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size .
Input Format
A single integer, , denoting the size of the staircase.
Constraints
.
Output Format
Print a staircase of size using
#
symbols and spaces.
Note: The last line must have spaces in it.
Sample Input
6
Sample Output
#
##
###
####
#####
######
Explanation
The staircase is right-aligned, composed of
#
symbols and spaces, and has a height and width of .
solution of the staircase in PHP :----------------------
<?php/* Write your PHP code here */
$n=6;
$d = 1;
for($col=$n;$col>0;$col--){
for($row = 1;$row <$col ;$row++){
echo" ";;
}
for($a = 0; $a <$d;$a++){
echo"#";
}
$d++;
echo"\n";
}
?>
------------------------------------------------------
Thank you
?>
------------------------------------------------------
Thank you
Comments
Post a Comment