Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace NumberPyramid
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10. int current = 1;
  11. bool stop = false;
  12.  
  13. for (int rows = 1; rows <= n; rows++)
  14. {
  15. for (int columns = 1; columns <= n; columns++)
  16. {
  17. if (current > n)
  18. {
  19. stop = true;
  20. break;
  21. }
  22. Console.Write($"{current} ");
  23. current++;
  24.  
  25. }
  26. if (stop)
  27. {
  28. break;
  29. }
  30. Console.WriteLine();
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement