using UnityEngine;

using System.Collections;


public class compareFunc : MonoBehaviour {


// Use this for initialization

void Start () {

int[] a = {2, 10, 3} ;

int[] b = {3, 9, 3} ;

Compare (a , b);

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

Compare2(a[i], b[i]);

}

}

void Compare(int[] a, int[] b){

int i;

for(i =0; i < a.GetLength(0); i++){

if(a[i] < b[i]){

print ("output   " + a[i] + "<" + b[i]);

}

else if(a[i] > b[i]){

print ("output   " + a[i] + ">" + b[i]);

}

else{

print ("output   " + a[i] + "=" + b[i]);

}

}

}

void Compare2(int a, int b){

if(a < b){

print ("output   " + a + "<" + b);

}

else if(a > b){

print ("output   " + a + ">" + b);

}

else{

print ("output   " + a + "=" + b);

}

}

// Update is called once per frame

void Update () {

}

}




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

입출금  (0) 2014.04.08
성적  (0) 2014.04.08
배열의 합  (0) 2014.04.08
함수 배열  (0) 2014.04.08
함수(매개변수 2개, 매개변수 3개, 형꺼 한개)  (0) 2014.04.07

using System.Collections;


public class ExTriangle : MonoBehaviour {


// Use this for initialization

void Start () {

float[] a = new float[]{1.0f, 2.0f, 3.0f, 4.0f, 5.0f} ;

float[] b = new float[]{10.0f, 20.0f, 30.0f, 40.0f, 50.0f} ;

float s = GetSum (a[0], a[1], a[2], a[3]);

print (s);

//float s1;

//s1 = GetSum1(a);

//print (s1);

float s2;

s2 = GetSum1 (a, b);

print (s2);

float sum3 = 0;

for(int i = 0; i < a.GetLength(0); i++){

sum3 = a[i] + b[i];

print (a[i] +" + " + b[i] + " = " + sum3);

}

}

/*

string GetDay(int day){

if(day == 1)

return "Hello";

else

return "world";

}

*/

float GetSum(float a, float b, float c, float d){

float sum = a + b + c + d;

return sum;

}

float GetSum1(float[] a, float[] b){

float sum1 = 0;

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

sum1 = a[i] + b[i];

print (a[i] + " + " + b[i] + "=" + sum1);

}

return sum1;

}

// Update is called once per frame

void Update () {

}

}



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

성적  (0) 2014.04.08
배열의 값을 비교(함수) 2가지 방법  (0) 2014.04.08
함수 배열  (0) 2014.04.08
함수(매개변수 2개, 매개변수 3개, 형꺼 한개)  (0) 2014.04.07
등차수열  (0) 2014.04.07

using UnityEngine;

using System.Collections;


public class ExTriangle : MonoBehaviour {


// Use this for initialization

void Start () {

float[] a = new float[]{1.0f, 2.0f, 3.0f, 4.0f} ;

float s = GetSum (a[0], a[1], a[2], a[3]);

print (s);

float s1;

s1 = GetSum1(a);

print (s1);

}

/*

string GetDay(int day){

if(day == 1)

return "Hello";

else

return "world";

}

*/

float GetSum(float a, float b, float c, float d){

float sum = a + b + c + d;

return sum;

}

float GetSum1(float[] a){

float sum1 = 0;

for(int i = 0; i < a.GetLength(0); i++){

sum1 = sum1 + a[i];

}

return sum1;

}

// Update is called once per frame

void Update () {

}

}


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

배열의 값을 비교(함수) 2가지 방법  (0) 2014.04.08
배열의 합  (0) 2014.04.08
함수(매개변수 2개, 매개변수 3개, 형꺼 한개)  (0) 2014.04.07
등차수열  (0) 2014.04.07
쾌걸 zoro  (0) 2014.04.07

리턴값 void, int, char, float, GameObject, 배열

파라미터 int, char, float, string, 배열


using System.Collections;


public class function : MonoBehaviour {


// Use this for initialization

void Start () {

PrintStar(3, 6);

//PrintNum(3, 6, 2);

}

void PrintStar(int count, int star){

int i, j;

string t;

int num = 0;

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

t = " ";

for(j = 0; j < star; j++){

t = t + " " + num;

num = num + 2;

}

print (t);

}

}

void PrintNum(int x, int y, int k){

int i, j;

string t = " ";

int num = 0;

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

t = " ";

for(j =0; j < y; j++){

t = t + " " + num;

num = num + k;

}

print (t);

}

}


void PrintBrother(int count, int star){

//카운트 x, y

int totalNum = count * star;

string text = " ";

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

text += ( i * 2 ) + " ";

if(( i + 1 ) % count == 0)

text += "\n";

}

print (text);

}


float Add(float a, float b, float c){

float sum;

sum = a + b + c;

return sum;

}

// Update is called once per frame

void Update () {

}

}



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

배열의 합  (0) 2014.04.08
함수 배열  (0) 2014.04.08
등차수열  (0) 2014.04.07
쾌걸 zoro  (0) 2014.04.07
나라 출력  (0) 2014.04.07

public class DC : MonoBehaviour {

int i, j, k = 1;

// Use this for initialization

void Start () {

int sum = 0;

for( i =1; sum < 100; i++){

j++;

sum = i + (2 * j) + (3 * k);

k++;

print ("i =" + i + "+ j =" + j + "+ k =" + k + " sum=" + sum);

}

}



using UnityEngine;

using System.Collections;


public class Zoro : MonoBehaviour {


// Use this for initialization

void Start () {

string text;

for(int i = 4; i >= 0; i--){

text = " ";

for(int j = 0; j < 5; j++){

if(i ==0){

text = text + "*";

}

else if( i>=1 && i < 4){

if(i > j)

text = text + " ";

if(i == j)

text = text + "*";

if(i < j)

text = text + " ";

}

else if(i==4){

text = text + "*";

}

}

print (text);

}

}


using UnityEngine;

using System.Collections;


public class ExSwitch2 : MonoBehaviour {


// Use this for initialization

void Start () {

string[] Country = new string[]{"KOREA", "JAPAN", "USA", "MEXICO", "FRANCE", "ENGLAND", "GABONG"} ;

//string country = "USA";

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

string text = Country[i] + " = " + " ";

string text1;

switch(Country[i]){

case "KOREA":

//print(text + "Asia");

case "JAPAN":

text1 = "ASIA";

print(text + text1);

break;

case "USA":

//print(text + "America");

case "MEXICO":

text1 = "ASIA";

print(text + text1);

break;

case "FRANCE":

text1 = "Europe";

print( text + text1);

break;

default:

text1 = "Unknown";

print (text + text1);

break;

}

//print (Country[i] + " - " + Country);

}

}

// Update is called once per frame

void Update () {

}

}



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

등차수열  (0) 2014.04.07
쾌걸 zoro  (0) 2014.04.07
정수값을 입력받고 문자로 치환해서 성적 구하기.(배열 if switch)  (0) 2014.04.07
배열과 if문 활용하여 성적 출력하기  (0) 2014.04.07
핀볼게임  (0) 2014.04.05


public class ExSwitch1 : MonoBehaviour {


// Use this for initialization

void Start () {

int[] Score = new int[] {40, 50,100, 90, 77, 89, 64} ;

char Result;

for(int i = 0; i < Score.Length; i++)

{

if(90 <= Score[i]){

//print (Score[i] + "- Pass ");

Result = 'A';

}

else if(80 <= Score[i] && Score[i] < 90){

//print (Score[i] + "- Pass ");

Result = 'B';

}

else if(70 <= Score[i] && Score[i] < 80){

//print (Score[i] + "- Retry ");

Result = 'C';

}

else if(60 <= Score[i] && Score[i] < 70){

//print (Score[i] + "- Retry ");

Result = 'D';

}

else{

//print (Score[i] + "- Fail ");

Result = 'F';

}

switch(Result){

case 'A': print (Score[i]+ " " + Result + "- Pass"); break;

case 'B': print (Score[i] + " " + Result + "- Pass"); break;

case 'C': print (Score[i] + " " + Result + "- Retry"); break;

case 'D': print (Score[i] + " " + Result + "- Retry"); break;

case 'F': print (Score[i] + " " + Result + "- Fail"); break;

}  

}

}


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

쾌걸 zoro  (0) 2014.04.07
나라 출력  (0) 2014.04.07
배열과 if문 활용하여 성적 출력하기  (0) 2014.04.07
핀볼게임  (0) 2014.04.05
중복된것 빼기 허허 슬퍼요  (0) 2014.04.05

using UnityEngine;

using System.Collections;


public class ExSwitch1 : MonoBehaviour {


// Use this for initialization

void Start () {

int i =0;

int[] Score = new int[] {40, 50,100, 90, 77, 89, 64} ;

for(i = 0; i < Score.Length; i++)

{

if(90 <= Score[i]){

print("A");

}

else if(80 <= Score[i] && Score[i] < 90){

print ("B");

}

else if(70 <= Score[i] && Score[i] < 80){

print ("C");

}

else if(60 <= Score[i] && Score[i] < 70){

print ("D");

}

else{

print ("F");

}

}

}

// Update is called once per frame

void Update () {

}

}




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

나라 출력  (0) 2014.04.07
정수값을 입력받고 문자로 치환해서 성적 구하기.(배열 if switch)  (0) 2014.04.07
핀볼게임  (0) 2014.04.05
중복된것 빼기 허허 슬퍼요  (0) 2014.04.05
배열 복사  (0) 2014.04.05

+ Recent posts