/*
* Created by SharpDevelop.
* User: dwa2007
* Date: 2011-10-16
* Time: ろ 12:05
*
* 螳 - 螳襦, 碁, 螳 螳
* 1 譴螳 1襦 , 譬豸 螳 覦レ朱 手覃伎 觜豺語 1 讀螳 襯 豈企.
*
* 覯企覃 豕朱, 譬豸′ 覯企覃 螳 豕一検朱 企, 企る 豺語 觜 讌 朱
* 覦襦 觜 豺語朱 企れ 螻 ろ.
*
* 螳 螻 覦 螳 覦 螳 螻, 螳 螻 伎 螳 螳螻, 覦 螳伎 .
*/
using System;
namespace test
{
class Program
{
public static void Main(string[] args)
{
int [,] Arr = new int[7,7];
int r,c,val;
val = 1;
r = 0; // row 豐蠍一誤
c = 3; // col 豐蠍一誤
Arr[r,c] = val;
while(val <= Arr.Length -1){
val++;
if(r == 0 && c == 0)
{
r++; //[0,0]企 [0,1]襦 螳 ロ 覦一伎殊 誤
} else {
if(r-- == 0) r = Arr.GetLength(0) - 1; //row螳 0企
if(c-- == 0) c = Arr.GetLength(1) - 1; //col 0企
}
if (Arr[r,c] != 0){ //誤 覦一伎殊 企 螳 譟伎覃
r += 2;
c += 1;
}
//Console.WriteLine("{0},{1}", r,c);
Arr[r,c] = val;
}
//蠍磯磯 螳 覲伎譯朱 螻
String s_val;
for(int i = 0; i < Arr.GetLength(0); i++){
for(int j = 0; j < Arr.GetLength(1); j++){
s_val = Arr[i,j].ToString();
s_val = (" " + s_val);
s_val = s_val.Substring(s_val.Length - 2); //right
Console.Write("{0} ", s_val);
}
Console.WriteLine();
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
/*
28 19 10 1 48 39 30
29 27 18 9 7 47 38
37 35 26 17 8 6 46
45 36 34 25 16 14 5
4 44 42 33 24 15 13
12 3 43 41 32 23 21
20 11 2 49 40 31 22
Press any key to continue . . .
*/