型[] 配列名 = new 型[要素数];
カテゴリー: Uncategorized
Unity C# 配列 for文
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
void Start()
{
int[,,] a = new int[3,4,2];
for(int i = 0; i < a.GetLength(0); ++i)
{
for(int j = 0; j < a.GetLength(1); ++j)
{
for(int k = 0; k < a.GetLength(2); ++k)
{
a[i,j,k] = i + j + k;//代入
Debug.Log(“a[“+ i + “,” + j + “,” + k + “]に代入する”);
}
}
}
}
// Update is called once per frame
void Update()
{
}
}
C# Unity 多次元配列
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
void Start()
{
int[,,] a = new int[3,4,2];
Debug.Log(a.Length);
Debug.Log(a.GetLength(1));
}
// Update is called once per frame
void Update()
{
}
}
C# Unity 配列
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
void Start()
{
int[] a = new int[50];
for(int i = 0; i < a.Length; ++i)
{
a[i] = i;
}
}
// Update is called once per frame
void Update()
{
}
}
C# for while文
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
void Start()
{
for (int i = 0; i < 5; ++i)
{
Debug.Log(i);
}
int i = 0;
while (i < 5)
{
Debug.Log(i);
++i;
}
}
// Update is called once per frame
void Update()
{
}
}
PHP dowhile
<?php
// $hp = 100;
$hp = -50;
// while ($hp > 0) {
// echo “Your HP: $hp” . PHP_EOL;
// $hp -= 15;
// }
do {
echo “Your HP: $hp” . PHP_EOL;
$hp -= 15;
} while ($hp > 0);