Advertisement
sanyakasarova

01. Number Pyramid

Jun 16th, 2021
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5. public static void Main()
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8.  
  9. int num = 1;
  10.  
  11. for (int row = 1; row <= n; row++)
  12. {
  13. for (int col = 1; col <= row; col++)
  14. {
  15. Console.Write(num + " ");
  16. num++;
  17.  
  18. if (num > n)
  19. {
  20. return;
  21. }
  22. }
  23. Console.WriteLine();
  24. }
  25.  
  26.  
  27. }
  28.  
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement