Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _13_Number_Pyramid
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- var num = 1;
- for (var row = 1; row <= n; row++)
- {
- for (var col = 1; col <= row; col++)
- {
- if (col >= 1)
- Console.Write(num);
- num++;
- if (num > n) break;
- }
- Console.WriteLine();
- if (num > n) break;
- }
- // пример 2 :
- /* var n = int.Parse(Console.ReadLine());
- var num = 1;
- for (var row = 1; row <= n; row++)
- {
- for (var col = 1; col <= row; col++)
- {
- if (col >= 1)
- Console.Write(" " + num);
- num++;
- if (num > n) break;
- }
- Console.WriteLine();
- if (num > n) break;
- }
- // край на пример 2 */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement