Guest User

Untitled

a guest
Jan 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #
  2. ##
  3. ###
  4. ####
  5. #####
  6. ######
  7.  
  8. function draw($size)
  9. {
  10. for ($i = 1; $i <=$size ; $i++)
  11. {
  12. $spaces = $size-$i;
  13. while ($spaces)
  14. {
  15. echo " ";
  16. $spaces--;
  17. }
  18. $stairs = 0;
  19. while ($stairs < $i)
  20. {
  21. echo "#";
  22. $stairs++;
  23. }
  24. echo "<br/>";
  25. }
  26. }
  27. draw(6);
  28. //output
  29. #
  30. ##
  31. ###
  32. ####
  33. #####
  34. ######
  35.  
  36. $max=5;
  37. for ( $i =1 ; $i<=$max;$i++) {
  38. for ( $space = 1; $space <= ($max-$i);$space++) {
  39. echo " ";
  40. }
  41. for ( $hash = 1; $hash <= $i;$hash ++ ) {
  42. echo "#";
  43. }
  44. echo "n";
  45. }
  46.  
  47. //PHP
  48.  
  49. $n = 6; // Number of rows.
  50. for($i=1;$i<=$n;$i++){
  51. echo str_repeat(' ', $n-$i) . str_repeat('#', $i);
  52. echo 'n';
  53. }
  54.  
  55. for(var i = 0; i < n; i++)
  56. {
  57. var s = "";
  58. for(var j = 0; j < n; j++)
  59. {
  60. if(n - i - 2 < j)
  61. {
  62. s += "#";
  63. }
  64. else
  65. {
  66. s += " ";
  67. }
  68. }
  69. console.log(s);
  70. }
  71.  
  72. $int = 7;
  73.  
  74. for($i = 1; $i<=$int; $i++){
  75. printf('%1$s%2$s%3$s',str_repeat(" ",$int-$i),str_repeat("#",$i),"n");
  76. }
  77.  
  78. $n = 6;
  79. for ($i = 0; $i < $n; $i++) {
  80. $pad = 1;
  81. for ($space = 0; $space < $n-$i-1; $space++) {
  82. $pad++;
  83. }
  84. echo str_pad('#', $pad,' ',STR_PAD_LEFT);
  85. for ($j = 0; $j < $i; $j++) {
  86. echo '#';
  87. }
  88. echo '<br>';
  89. }
  90.  
  91. <?php
  92.  
  93. $handle = fopen("php://stdin","r");
  94.  
  95. $n = intval(fgets($handle));
  96.  
  97.  
  98. for ($rows = 0; $rows < $n; $rows++) {
  99.  
  100. for ($columns = 0; $columns < $n - $rows - 1; $columns++) {
  101.  
  102. echo " ";
  103. }
  104.  
  105. for ($columns = 0; $columns < $rows + 1; $columns++) {
  106.  
  107. echo "#";
  108. }
  109.  
  110. echo "n";
  111.  
  112. }
  113.  
  114. ?>
  115.  
  116. function staircase($n){
  117. foreach (range(1, $n) as $i)
  118. print( str_repeat(' ',$n-$i).str_repeat('#',$i)."n");
  119. }
  120.  
  121. function StairCase(n){
  122. let x = [];
  123. for(let i = 0; i<n; i++){
  124. while(x.length < n){
  125. x.push(" ");
  126. }
  127. x.shift();
  128. x.push("#");
  129. console.log(x.join(''));
  130. } } //StairCase(6)
Add Comment
Please, Sign In to add comment