알 수 없는 사용자
2014. 4. 22. 09:55
.4453125using UnityEngine;
using System.Collections;
public class Ex6_4 : MonoBehaviour {
// Use this for initialization
void Start () {
int index = -1;
int[] npc_hp = new int[5]{10, 20, 30, 40, 50} ;
FindMax(npc_hp, ref index);
print("Max Value = " + npc_hp[index] + ",index = " + index);
}
static void FindMax(int[] npc_hp, ref int index){
//npc_hp = new int[5]; 초기화 하는법.
int max = int.MinValue;
index = -1;
for(int i = 0; i < npc_hp.Length; i++)
{
print ("max" + npc_hp[i]);
if( max < npc_hp[i]){
max = npc_hp[i];
index = i;
}
}
print (max);
}
// Update is called once per frame
void Update () {
}
}