using UnityEngine;
using System.Collections;
public class ExWhile5: MonoBehaviour {
// Use this for initialization
void Start () {
string[] npc_name = new string[]{"npc1", "npc2", "npc3", "boss", "npc4"} ;
int[] npc_hp = new int[]{-100, -150, -200, -1000, -250} ;
int i;
string text;
int max_hp = int.MinValue; //at least error no minvalue
//float max_mp = float.MinValue;
int min_hp = int.MaxValue;
string max_name = "";
string min_name="";
for(i=0; i < npc_name.Length; i++){
text = npc_name[i] + "," + " [" + npc_hp[i] + "]";
print (text);
if( max_hp < npc_hp[i]){
max_hp = npc_hp[i];
max_name = npc_name[i];
}
if( min_hp > npc_hp[i]){
min_hp = npc_hp[i];
min_name = npc_name[i];
}
}
print("max= " + max_hp + ", npc_name= " + max_name);
print ("min= " + min_hp + ", min_name= " + min_name);
}
// Update is called once per frame
void Update () {
}
}
'Computer Language > 유니티' 카테고리의 다른 글
변태같은 코드 ㅋㅋㅋ for문 (0) | 2014.04.04 |
---|---|
pow 2의 제곱승 2014 출력하기 (0) | 2014.04.04 |
while문& for문 별찍기 놀이 (0) | 2014.04.04 |
while (0) | 2014.04.04 |
배열 (0) | 2014.03.31 |