using UnityEngine;

using System.Collections;


public class ExWhile9 : MonoBehaviour {


// Use this for initialization

void Start () {

int i = 0;

int sum = 0;

int avg = 0;

do{

sum = sum + i;

i +=1;

print(i);

}while(i <= 100);

avg = sum / i;

print (sum);

print(avg);

}

// Update is called once per frame

void Update () {

}

}



*주의사항

while ; 세미콜론 붙음

do1번 while2번 순서대로 흘러가게 됨.


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

곱하기 할때 나머지를 이용해서  (0) 2014.04.05
시간 분 초  (0) 2014.04.05
변태같은 코드 ㅋㅋㅋ for문  (0) 2014.04.04
pow 2의 제곱승 2014 출력하기  (0) 2014.04.04
npc 최대값 최소값 이름 출력  (0) 2014.04.04

for( i=0; num<2048; i=i+1, num = num * 2, print ("Pow(2," + i + ") " + "=" + num))

{

}


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

시간 분 초  (0) 2014.04.05
do while 문 (합계와 평균을 구함)  (0) 2014.04.04
pow 2의 제곱승 2014 출력하기  (0) 2014.04.04
npc 최대값 최소값 이름 출력  (0) 2014.04.04
while문& for문 별찍기 놀이  (0) 2014.04.04

using UnityEngine;

using System.Collections;


public class Chap_2048 : MonoBehaviour {

// Use this for initialization

void Start () {

int num = 1;

int i = 0;

/*

while(true){

print ("Pow(2," + i + ") " + "=" + num);

i += 1;

num = num * 2 ;

if(num > 2048)

break;

}

*/

/*

for( i=1; num<2048; i++)

{

num = num * 2;

print ("Pow(2," + i + ") " + "=" + num);

}

*/

}

// Update is called once per frame

void Update () {

}

}


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

do while 문 (합계와 평균을 구함)  (0) 2014.04.04
변태같은 코드 ㅋㅋㅋ for문  (0) 2014.04.04
npc 최대값 최소값 이름 출력  (0) 2014.04.04
while문& for문 별찍기 놀이  (0) 2014.04.04
while  (0) 2014.04.04

+ Recent posts