using UnityEngine;

using System.Collections;


public class dup : MonoBehaviour {


// Use this for initialization

void Start () {

int[] numbers = { 10, 20, 30, 10, 50, 60, 30, 90, 60, 80 };

int[] result = new int[10];

int i, j, k = 0;

for(i=0;  i < numbers.Length; i++){

for(j=0; j < numbers.Length; j++){

if(result[j] == numbers[i])

break;

}

if(j == 10){

result[k] = numbers[i];

k++;

}

//print (numbers[i] + " ," + result[i]);

}

for(i = 0; i < k; i++){

print (result[i]);

}

}

}




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

배열과 if문 활용하여 성적 출력하기  (0) 2014.04.07
핀볼게임  (0) 2014.04.05
배열 복사  (0) 2014.04.05
자리수  (0) 2014.04.05
곱하기 할때 나머지를 이용해서  (0) 2014.04.05

    int[] numbers = { 10, 20, 30, 10, 50, 60, 30, 90, 60, 80 };

int[] result = new int[10];

int i = 0;

for(i=0;  i < numbers.Length; i++){

result[i] = numbers[i];


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

핀볼게임  (0) 2014.04.05
중복된것 빼기 허허 슬퍼요  (0) 2014.04.05
자리수  (0) 2014.04.05
곱하기 할때 나머지를 이용해서  (0) 2014.04.05
시간 분 초  (0) 2014.04.05

using UnityEngine;

using System.Collections;


public class muladd : MonoBehaviour {


// Use this for initialization

void Start () {

int num = 3174234;

int n = num;

int digit = 1;

while(true){

n /= 10;

if(n == 0)

break;

digit += 1;

}

print ("num = " + num + ", digit = " + digit);

int n1 = 0;

int div = 1;

for(int i = 1; i < digit; i++){

div = 10 * div;

}

print ("div=" + div);

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

n1 = num / div;

num = num % div;

print ("div = " + div + ", num = " + num + ", n1 = " + n1);

div /= 10;

}

}

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

중복된것 빼기 허허 슬퍼요  (0) 2014.04.05
배열 복사  (0) 2014.04.05
곱하기 할때 나머지를 이용해서  (0) 2014.04.05
시간 분 초  (0) 2014.04.05
do while 문 (합계와 평균을 구함)  (0) 2014.04.04

using UnityEngine;

using System.Collections;


public class muladd : MonoBehaviour {


// Use this for initialization

void Start () {

int a = 256;

int b = 317;

int s3 = a * (b/100);

print ("s3"+ " " + s3);

int s2 = a * (b/10%10);

print ("s2"+ " " + s2);

int s1 = a * (b%100%10);

print ("s1"+ " " + s1);

int sum = s1 + s2*10 + s3*100;

print ("sum" + " " + sum);

for( ; ; ){

}

//int sum = a * b;

//print("sum" + sum);

}

// Update is called once per frame

void Update () {

}

}


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

배열 복사  (0) 2014.04.05
자리수  (0) 2014.04.05
시간 분 초  (0) 2014.04.05
do while 문 (합계와 평균을 구함)  (0) 2014.04.04
변태같은 코드 ㅋㅋㅋ for문  (0) 2014.04.04

using UnityEngine;

using System.Collections;


public class Ex : MonoBehaviour {

// Use this for initialization

void Start () {

int total = 200000;

int day = 0 , hour = 0, min = 0, sec = 0;

int oneday =  24 * 60 * 60;

day = total / oneday;

int left = total - day * oneday;

print("left" + left);

left = total % oneday;

print("left" + left);

hour = left /3600;

print ("hour" + hour);

left = left - hour * 3600;

print ("left = " + left);

min = left/60;

print ("min = " + min);

left = left - min * 60;

print ("left = " + left);

sec = left;

print ("sec= " + sec);

print ("Day =" + day + " " + hour + " " + min + " " + sec);

/*

int onehour = 24 * 60;

hour = (total - oneday) / onehour;

//min = min / 

int oneminute = 60;

min = (total - oneday - onehour) / oneminute; 

sec = total % 60;

print ("Day =" + day + " " + hour + " " + min + " " + sec);

*/

}

// Update is called once per frame

void Update () {

}

}


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

자리수  (0) 2014.04.05
곱하기 할때 나머지를 이용해서  (0) 2014.04.05
do while 문 (합계와 평균을 구함)  (0) 2014.04.04
변태같은 코드 ㅋㅋㅋ for문  (0) 2014.04.04
pow 2의 제곱승 2014 출력하기  (0) 2014.04.04

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

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

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