Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. int j = 10;
  2. int k = 0;
  3. while (j > 0)
  4. {
  5. if (k <= j)
  6. {
  7. Console.Write("* ");
  8. Console.WriteLine();
  9. }
  10. j--;
  11. } Console.WriteLine();
  12.  
  13. for (initializer; condition; iterator) {
  14. body;
  15. }
  16.  
  17. initializer;
  18. while (condition) {
  19. body;
  20. iterator;
  21. }
  22.  
  23. // Height and width of the triangle
  24. var h = 8;
  25. var w = 30;
  26.  
  27. // The iterator variables
  28. var y = 1;
  29. var x = 1;
  30.  
  31. // Print the tip of the triangle
  32. Console.WriteLine("*");
  33.  
  34. y = 1;
  35. while (y++ <h) {
  36. // Print the bit of left wall
  37. Console.Write("*");
  38.  
  39. // Calculate length at this y-coordinate
  40. var l = (int) w*y/h;
  41.  
  42. // Print the hypothenus bit
  43. x = 1;
  44. while (x++ <l-3) {
  45. Console.Write(" ");
  46. }
  47. Console.WriteLine("*");
  48. }
  49.  
  50. // Now print the bottom edge
  51. x = 0;
  52. while (x++ <w) {
  53. Console.Write("*");
  54. }
  55.  
  56. *
  57. * *
  58. * *
  59. * *
  60. * *
  61. * *
  62. * *
  63. * *
  64. ******************************
  65.  
  66. int x = 1;
  67. int j = 10;
  68. int k = 0;
  69. while (j > 0)
  70. {
  71. if (k <= j)
  72. {
  73. Console.Write("* ");
  74. }
  75. if (j >= 1)
  76. {
  77. int temp = x;
  78. while (temp >= 0)
  79. {
  80. Console.Write(" ");
  81. temp--;
  82. }
  83. x = x + 1;
  84. Console.Write("*");
  85.  
  86. }
  87. Console.WriteLine();
  88. j--;
  89. }
  90. Console.WriteLine();
  91. double f = Math.Round(x * 1.5);
  92. while (f != 0)
  93. {
  94. Console.Write("*");
  95. f--;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement