반응형
1.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{200, 200, 200},
{100, 100, 200},
{100, 100, 100},
{100, 100, 100}
};
Console.WriteLine("****************************************");
Console.WriteLine("{0}", arr.GetLength(0)); //row
Console.WriteLine("{0}", arr.GetLength(1)); //col
Console.WriteLine("****************************************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0, 2}", arr[i, j]);
}
Console.WriteLine(" ");
Console.WriteLine(" ");
}
}
}
}
------------
2.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{100, 100, 100},
{100, 100, 301},
{100, 303, 302},
};
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("****************************************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++)
{
Console.Write(" {0, 2}", arr[i, j]);
}
Console.WriteLine();
Console.WriteLine();
}
}
}
}
-----
3.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{100, 308, 307},
{200, 200, 100},
{303, 305, 200},
{304, 306, 100},
};
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("***************************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine(" ");
Console.WriteLine(" ");
}
}
}
}
----
4.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{309, 306, 100, 100},
{200, 200, 100, 200},
};
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("*****************************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine(" ");
Console.WriteLine(" ");
}
}
}
}
-----
5.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{309, 306, 100, 100},
{200, 200, 100, 200},
};
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("***********************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine(" ");
Console.WriteLine(" ");
}
}
}
}
----
6.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{100, 100, 100, 100, 100},
{312, 312, 305, 100, 100}
};
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("*******************************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine("");
}
}
}
}
----
7.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{312, 305, 100 },
{313, 311, 310 },
{309, 306, 100 },
{200, 200, 100 },
{100, 200, 200 },
};
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("*******************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine(" ");
}
}
}
}
----
8.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{200, 200, 200, 100, 100},
{100, 303, 305, 200, 200},
{308, 304, 311, 100, 200},
};
Console.WriteLine("*************************");
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("*************************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine(" ");
Console.WriteLine(" ");
}
}
}
}
----
9.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{100, 100, 200, 200 },
{100, 200, 200, 200 },
{200, 100, 100, 100 },
{100, 100, 100, 100 }
};
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("************************");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine(" ");
}
}
}
}
--
10. 캐릭터 위치
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace study08
{
class App
{
public App()
{
//배열 선언 및 초기화
int[,] arr = {
{100, 100, 200, 200 },
{100, 200, 200, 200 },
{200, 100, 100, 100 },
{100, 100, 100, 100 }
};
Console.WriteLine("************* MAP **********");
Console.WriteLine("{0}", arr.GetLength(0));
Console.WriteLine("{0}", arr.GetLength(1));
Console.WriteLine("************* MAP **********");
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(" {0}", arr[i, j]);
}
Console.WriteLine(" ");
}
int[,] heroArr;
heroArr = new int[4, 4];
Console.WriteLine("************* HERO **********");
heroArr[2, 1] = 1;
Console.WriteLine("{0}",heroArr.GetLength(0));
Console.WriteLine("{0}", heroArr.GetLength(1));
Console.WriteLine("************* HERO **********");
for (int i = 0; i < heroArr.GetLength(0); i++) {
for (int j = 0; j < heroArr.GetLength(1); j++) {
Console.Write(" {0}", heroArr[i, j]);
}
Console.WriteLine(" ");
}
}
}
}
반응형
'C# > C#언어' 카테고리의 다른 글
0318_ 다차원 _ 2차원 배열 isometric view (0) | 2021.03.18 |
---|---|
0318 _ 다차원 배열 _ 맵 바꾸기 예제 (0) | 2021.03.18 |
0317 _ abstract 연습 예제 (0) | 2021.03.17 |
0317_ interface 연습 (0) | 2021.03.17 |
0317 _ 문) 클래스를 만들어서 배열 만들기 (0) | 2021.03.17 |