Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Matrix Pattern
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here //Console.Write("Enter your Number:"); int n = 4; int[, ] a = new int[n, n]; int printValue = 1; int c1 = 0, c2 = n - 1; while (printValue <= n * n) { //Right Direction Move for (int i = c1; i <= c2; i++) a[c1, i] = printValue++; //Down Direction Move for (int j = c1 + 1; j <= c2; j++) a[j, c2] = printValue++; //Left Direction Move for (int i = c2 - 1; i >= c1; i--) a[c2, i] = printValue++; //Up Direction Move for (int j = c2 - 1; j >= c1 + 1; j--) a[j, c1] = printValue++; c1++; c2--; } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { Console.Write(a[i, j] + "\t"); } Console.WriteLine(); } Console.Read(); } } }
run
|
edit
|
history
|
help
0
Reed Solomon Demo
NumberToWords C# Structural
input
Url Encode
test
Volatile madness
Reward
cs002
Roman Numbers - Sorting
Lesson1