728x90
SMALL

// 2次元配列で地を表示する2

using System;

 

public class Lesson05

{

    public static void Main()

    {

        string[][] worldMap = new string[10][];

        for (int i = 0; i < worldMap.Length; i++)

        {

            worldMap[i] = new string[20];

        }

        worldMap[0][0] = "";

        worldMap[0][19] = "";

        worldMap[9][19] = "";

 

        for (int i = 0; i < worldMap.Length; i++)

        {

            Console.Write(i + ":");//행에 번호 붙이고 : 생김

           

            for (int j = 0; j < worldMap[i].Length; j++)

            {

                if (worldMap[i][j] == null)

                {

                    if(i % 2 ==0)

                    {

                    worldMap[i][j] = "+";

                    }

                    else

                    {

                        worldMap[i][j] = "";

                    }

                      

                    }

                Console.Write(worldMap[i][j]);

            }

            Console.WriteLine();

        }

    }

}

////////////////////////

/////////////////

0:++++++++++++++++++

1:森森森森森森森森森森森森森森森森森森森森

2:++++++++++++++++++++

3:森森森森森森森森森森森森森森森森森森森森

4:++++++++++++++++++++

5:森森森森森森森森森森森森森森森森森森森森

6:++++++++++++++++++++

7:森森森森森森森森森森森森森森森森森森森森

8:++++++++++++++++++++

9:森森森森森森森森森森森森森森森森森森森町

////////////////

/////

 

// 2次元配列で地を表示する2

using System;

 

public class Lesson05

{

    public static void Main()

    {

        string[][] worldMap = new string[10][];

        for (int i = 0; i < worldMap.Length; i++)

        {

            worldMap[i] = new string[20];

        } //2차원 지도 만들기

        worldMap[0][0] = "";

        worldMap[0][19] = "";

        worldMap[9][19] = "";

 

        for (int i = 0; i < worldMap.Length; i++)

        {

            Console.Write(i + ":");//행에 번호 붙이고 : 생김

           

            for (int j = 0; j < worldMap[i].Length; j++)

            {

                if (worldMap[i][j] == null)

                {

                    if(i % 2 ==0 || j % 3==0) //길 만들기

                    {

                    worldMap[i][j] = "+";

                    }

                    else

                    {

                        worldMap[i][j] = "";

                    }

                      

                    }

                Console.Write(worldMap[i][j]);

            }

            Console.WriteLine();

        }

    }

}

/////////////

/////////

0:++++++++++++++++++

1:+森森+森森+森森+森森+森森+森森+

2:++++++++++++++++++++

3:+森森+森森+森森+森森+森森+森森+

4:++++++++++++++++++++

5:+森森+森森+森森+森森+森森+森森+

6:++++++++++++++++++++

7:+森森+森森+森森+森森+森森+森森+

8:++++++++++++++++++++

9:+森森+森森+森森+森森+森森+森森+

/////////

//

///

 

// を出力してみよう

using System;

 

public class Lesson05

{

    public static void Main()

    {

        string[][] areaMap = new string[5][];

        for (int i = 0; i < areaMap.Length; i++)

        {

            areaMap[i] = new string[10];

        }

 

        for (int i = 0; i < areaMap.Length; i++)

        {

            for (int j = 0; j < areaMap[i].Length; j++)

            {

                if(i%2 ==1 || j%2 ==1)

                {

                    areaMap[i][j] = ".";

                }

                else

                {

                areaMap[i][j] = "+";

                }

                Console.Write(areaMap[i][j]);

            }

            Console.WriteLine();

        }

    }

}

//////

+.+.+.+.+.

..........

+.+.+.+.+.

..........

+.+.+.+.+.

/////

 

728x90

설정

트랙백

댓글