Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using System.Collections.Generic;
- using System;
- namespace NestedLoops
- {
- class Program
- {
- static int[] row;
- static int cols;
- public static void Main(string[] args)
- {
- //въведи число по-малко от 5 ако не искаш да умреш :Д
- int number = int.Parse(Console.ReadLine());
- cols = number;
- row = new int[cols];
- NestedLoops(0);
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey(true);
- }
- static void NestedLoops(int currentLoop)
- {
- if (currentLoop == cols)
- {
- PrintLoops();
- return;
- }
- for (int counter = 1; counter <= cols; counter++)
- {
- row[currentLoop] = counter;
- NestedLoops(currentLoop + 1);
- }
- }
- static void PrintLoops()
- {
- for (int i = 0; i < cols; i++)
- {
- Console.Write("{0} ", row[i]);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment