Teo_Yanchev

PrintTriangels - C# Fundamentals

Sep 9th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. namespace _4.PrintingTriangle
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int n = int.Parse(Console.ReadLine());
  11.  
  12. for (int row = 1; row <= n; row++)
  13. {
  14. for (int col = 1; col <= row; col++)
  15. {
  16. Console.Write($"{col} ");
  17. }
  18. Console.WriteLine();
  19. }
  20.  
  21. for (int row = n - 1; row > 0; row--)
  22. {
  23. for (int col = 1; col <= row; col++)
  24. {
  25. Console.Write($"{col} ");
  26. }
  27. Console.WriteLine();
  28. }
  29.  
  30. Console.WriteLine();
  31. }
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment