1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Program { //http://ja.doukaku.org/99/投稿用
    static void Main(string[] args) {
        string search = "ウオリ";
        System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(new string[] { "リオウウリウ", "ウオリウオリ", "オリリオリウ", "リリオオウオ" });
        int width = list[0].Length; int height = list.Count;
        for(int y = 0; y < list.Count; y++) { //縦ループ
            for(int x = 0; x < list[y].Length; x++) { //横ループ
                for(int dx = -1; dx <= 1; dx++) { //左右方向ループ           -1は上、左 1は下、右を表す
                    for(int dy = -1; dy <= 1; dy = dy + (dx == 0 ? 2 : 1)) { //上下方向ループ 
                        try {                //dxが0の時はdyを2ステップして、両方が0にならないようにする                     
                            string strb = "";
                            for(int i = 0; i < search.Length; i++) { //iは移動量
                                strb += list[y + i * dy][x + i * dx];} //移動方向をdy,dxで乗算することで反転
                            if(search == strb) {
                                string directionStr = "";
                                if(dx < 0) directionStr += "左"; 
                                else if(dx > 0) directionStr += "右";
                                if(dy < 0) directionStr += "上";
                                else if(dy > 0) directionStr += "下";
                                System.Console.WriteLine("(" + x + "," + y + ")" + "," + directionStr);}
                        } catch(System.ArgumentOutOfRangeException) { } catch(System.IndexOutOfRangeException) { }}}}}
        System.Console.ReadLine();}}