Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace NestedLoopsExercise1NumberPyramid
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int current = 1; // 2nd
- bool isBigger = false; // 3rd
- for (int rows = 1; rows <= n; rows++)
- {
- for (int cols = 1; cols <= rows; cols++)
- {
- if (current > n) // 4th
- {
- isBigger = true;
- break;
- }
- Console.Write($"{current} "); // 5th
- current++;
- }
- if (isBigger) // 6th
- {
- break;
- }
- Console.WriteLine(); // 7th
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment