'Computer Language > 유니티' 카테고리의 다른 글

arraylist, queue, stack, hashtable, sortedlist  (0) 2014.05.19
바둑게임 선생님 일차!  (0) 2014.05.19
가변 배열  (0) 2014.05.16
다차원 배열  (0) 2014.05.16
시험 예제  (0) 2014.05.16

using UnityEngine;

using System.Collections;


public class chap10_6 : MonoBehaviour {


// Use this for initialization

void Start () {

/*

int[][] jagged = new int[3][];

jagged[0] = new int[5]{1, 2, 3, 4, 5} ;

jagged[1] = new int[5]{10,20,30} ;

jagged[2] = new int[5]{100,200} ;

*/

int[][] jagged2 = new int[2][] {

new int[]{1000, 2000} ,

new int[]{4, 5, 6, 7}

} ;

foreach(int[] arr in jagged2){

for(int i = 0; i < arr.GetLength(0); i++){

print(string.Format("arr[{0}] = {1}", i, arr[i]));

}

}

}

// Update is called once per frame

void Update () {

}

}



'Computer Language > 유니티' 카테고리의 다른 글

바둑게임 선생님 일차!  (0) 2014.05.19
바둑돌  (0) 2014.05.16
다차원 배열  (0) 2014.05.16
시험 예제  (0) 2014.05.16
이차원 배열 getUpperBound []<- []  (0) 2014.05.16

using UnityEngine;

using System.Collections;


using System;

public class chap10_5 : MonoBehaviour {


// Use this for initialization

void Start () {

int[,,] array = new int [4, 3, 2]{

{{1, 2} , {3, 4} , {5, 6}} ,

{{1, 2} , {3, 4} , {5, 6}} ,

{{1, 2} , {3, 4} , {5, 6}} ,

{{1, 2} , {3, 4} , {5, 6}}

} ;

for(int i = 0; i < array.GetLength(0); i++){

for(int j = 0; j < array.GetLength(1); j++){

// for(int k = 0; k < array.GetLength(2); k++){

// print (string.Format("array[{0},{1},{2}] = {3}", i, j, k, array[i, j, k]));

for(int k = array.GetLowerBound(2); k <= array.GetUpperBound(2); k++){

print (string.Format("array[{0},{1},{2}] = {3}", i, j , k , array[i, j , k]));

}

}

}

}

// Update is called once per frame

void Update () {

}

}


'Computer Language > 유니티' 카테고리의 다른 글

바둑돌  (0) 2014.05.16
가변 배열  (0) 2014.05.16
시험 예제  (0) 2014.05.16
이차원 배열 getUpperBound []<- []  (0) 2014.05.16
이차원 배열 선언과 동시에 초기화  (0) 2014.05.16

'Computer Language > 유니티' 카테고리의 다른 글

가변 배열  (0) 2014.05.16
다차원 배열  (0) 2014.05.16
이차원 배열 getUpperBound []<- []  (0) 2014.05.16
이차원 배열 선언과 동시에 초기화  (0) 2014.05.16
find 함수  (0) 2014.05.16

using UnityEngine;

using System.Collections;

using System;


public class chap10_Cube : MonoBehaviour {

void Show(int[,] array){

print("upper1 = " + array.GetUpperBound(0));

print("upper2 = " + array.GetUpperBound(1));

for(int i = 0; i < array.GetUpperBound(0) + 1; i++){

for(int j = 0; j < array.GetUpperBound(1) + 1; j++){

print (string.Format("array[{0}, {1}] = {2}", i, j , array[i, j]));

}

}

}

// Use this for initialization

void Start () {

int[,] array = new int[2, 3]{{1, 2, 3} , {4, 5, 6}} ;

// array[0, 0] = 1;

// array[0, 1] = 2;

// array[0, 2] = 3;

int[,] array2 = new int[,]{{1, 2, 3} , {4, 5, 6}} ;

int[,] array3 = {{1, 2, 3} , {4, 5, 6}} ;

Show (array2);

Show (array3);

Show (new[,]{{11, 22, 33} , {44, 55, 66}} );

int[] arr = { 1, 2, 3, 4, 5 };

}

// Update is called once per frame

void Update () {

}

}


'Computer Language > 유니티' 카테고리의 다른 글

다차원 배열  (0) 2014.05.16
시험 예제  (0) 2014.05.16
이차원 배열 선언과 동시에 초기화  (0) 2014.05.16
find 함수  (0) 2014.05.16
c# array2  (0) 2014.05.16

using UnityEngine;

using System.Collections;

using System;


public class chap10_Cube : MonoBehaviour {

void Show(int[,] array){

for(int i = 0; i < 2; i++){

for(int j = 0; j < 3; j++){

print (string.Format("array[{0}, {1}] = {2}", i, j , array[i, j]));

}

}

}

// Use this for initialization

void Start () {

int[,] array = new int[2, 3]{{1, 2, 3} , {4, 5, 6}} ;

// array[0, 0] = 1;

// array[0, 1] = 2;

// array[0, 2] = 3;

int[,] array2 = new int[,]{{1, 2, 3} , {4, 5, 6}} ;

int[,] array3 = {{1, 2, 3} , {4, 5, 6}} ;

Show (array2);

Show (array3);

Show (new[,]{{11, 22, 33} , {44, 55, 66}} );

}

// Update is called once per frame

void Update () {

}

}


'Computer Language > 유니티' 카테고리의 다른 글

시험 예제  (0) 2014.05.16
이차원 배열 getUpperBound []<- []  (0) 2014.05.16
find 함수  (0) 2014.05.16
c# array2  (0) 2014.05.16
c# array  (0) 2014.05.16

public GameObject[] Cubes = new GameObject[5];

GameObject myCube;

// Use this for initialization

void Start () {

myCube = GameObject.Find("Cube3");

int i = Array.IndexOf(Cubes, myCube);

print ("myCube index is " + i);

}




'Computer Language > 유니티' 카테고리의 다른 글

이차원 배열 getUpperBound []<- []  (0) 2014.05.16
이차원 배열 선언과 동시에 초기화  (0) 2014.05.16
c# array2  (0) 2014.05.16
c# array  (0) 2014.05.16
int[] a -> System.Array  (0) 2014.05.16

using UnityEngine;

using System.Collections;

using System;

public class chap10_4 : MonoBehaviour {

void Print(int v){

print (string.Format("{0}", v));

}

// Use this for initialization

void Start () {

int[] scores = new int[]{80, 74, 81, 90, 34, 90} ;

foreach(int s in scores)

print (string.Format("{0}", s));

Array.Sort(scores);

Array.ForEach<int>(scores, new Action<int>(Print));

print(string.Format("number of dimensions : {0}", scores.Rank));

print (string.Format("linear Search: 90 is at {0}", Array.IndexOf(scores, 90)));

print (string.Format("Reverse Search: 90 is at {0}", Array.LastIndexOf(scores, 90)));

print(string.Format("Old Length of scores : {0}", scores.Length));

Array.Resize<int>(ref scores, 10);

print(string.Format("Old Length of scores : {0}", scores.Length));

scores[6] = 22;

scores[7] = 77;

Array.ForEach<int>(scores, new Action<int>(Print));

}

// Update is called once per frame

void Update () {

}

}




'Computer Language > 유니티' 카테고리의 다른 글

이차원 배열 선언과 동시에 초기화  (0) 2014.05.16
find 함수  (0) 2014.05.16
c# array  (0) 2014.05.16
int[] a -> System.Array  (0) 2014.05.16
using 사용법  (0) 2014.05.16

using UnityEngine;

using System.Collections;

using System;

public class chap10_4 : MonoBehaviour {

void Print(int v){

print (string.Format("{0}", v));

}

// Use this for initialization

void Start () {

int[] scores = new int[]{80, 74, 81, 90, 34} ;

foreach(int s in scores)

print (string.Format("{0}", s));

Array.Sort(scores);

Array.ForEach<int>(scores, new Action<int>(Print));

print(string.Format("number of dimensions : {0}", scores.Rank));

print (string.Format("linear Search: 90 is at {0}", Array.IndexOf(scores, 90)));

   print (string.Format("Reverse Search: 90 is at {0}", Array.LastIndexOf(scores, 90)));


}

// Update is called once per frame

void Update () {

}

}





'Computer Language > 유니티' 카테고리의 다른 글

find 함수  (0) 2014.05.16
c# array2  (0) 2014.05.16
int[] a -> System.Array  (0) 2014.05.16
using 사용법  (0) 2014.05.16
배열 선언  (0) 2014.05.16


  

    int[] array = new int[] {10, 30, 20, 7, 1} ;

print (string.Format("Type of array : {0}", array.GetType()));

print (string.Format("Base Type of array : {0}", array.GetType().BaseType));


'Computer Language > 유니티' 카테고리의 다른 글

c# array2  (0) 2014.05.16
c# array  (0) 2014.05.16
using 사용법  (0) 2014.05.16
배열 선언  (0) 2014.05.16
추상 클래스  (0) 2014.05.13

+ Recent posts