Created
May 1, 2017 11:18
-
-
Save Osinko/d4f0497942c239e2d1ebee9cbdcb3548 to your computer and use it in GitHub Desktop.
狙った桁の抽出
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class TargetDigit : MonoBehaviour | |
{ | |
void Start() | |
{ | |
print(Digit(123456789, 6)); //7桁目を表示(変数digは0を含んでカウントしている) | |
} | |
public int Digit(int value, int dig) { | |
int n=1; | |
for (int i = 0; i < dig; i++) { n *= 10; } | |
int temp = value / n; | |
return temp%10; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment