1. 이중 while

using UnityEngine;

using System.Collections;


public class ExWhile4 : MonoBehaviour {

void Start(){

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

int row = -1;

int col = 0;

int sum = 0;

string text = " ";

while(true){

row += 1;

print (count[row]);

if(count[row] == 0){

break;

}

col = 0;

text = " ";

while(col<count[row]){

col +=1;

text = text + "*";

}

print (text);

}

}

}



2. 2중 for

using UnityEngine;

using System.Collections;


public class ExWhile4 : MonoBehaviour {

void Start(){

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

int row = -1;

int col = 0;

int sum = 0;

string text = " ";

for(row = 0; count[row]>0; row++){

//print(count[row]);

text = " ";

for(col = 0; col < count[row]; col++){

text = text + "*";

}

print (text);

}

}

}

3. while문 for문

using UnityEngine;

using System.Collections;


public class ExWhile4 : MonoBehaviour {

void Start(){

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

int row = -1;

int col = 0;

int sum = 0;

string text = " ";

while(true)

{

row++;

if(count[row]==0){

break;

}

col = 0;

text = " ";

//for

for(col =0; col < count[row]; col++){

text = text + "*";

}

print(text);

// }

}

}

}



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

pow 2의 제곱승 2014 출력하기  (0) 2014.04.04
npc 최대값 최소값 이름 출력  (0) 2014.04.04
while  (0) 2014.04.04
배열  (0) 2014.03.31
C# String Format  (0) 2014.03.31

+ Recent posts