|
|
back to boardC# Accepted using System.IO; using System; class Program { static void Main() { int size = Int32.Parse(Console.ReadLine()); int[,] arr=new int[size,size]; int count=1; for(int x=size;x>=0;x--) { int y=0; int xx=x; bool exc=false; while(!exc) { try { arr[xx,y]=count; count++; xx++; y++; } catch { exc=true; break; } } }
for(int y=1;y<=size-1;y++) { int x=0; int yy=y; bool exc=false; while(!exc) { try { arr[x,yy]=count; count++; x++; yy++; } catch { exc=true; break; } } }
for(int x=0;x<size;x++) { for(int y=0;y<size;y++) { Console.Write(arr[y,x]+" "); } Console.WriteLine(); }
} } |
|
|