Created
September 10, 2021 06:15
-
-
Save kurokuru/ba55204cfdb870209165a94355b13edc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 System; | |
using System.Linq; | |
public class Hello{ | |
public static void Main(){ | |
// Your code here! | |
int value = 1234; // value > 0 を満たさないといけない | |
var digit = Enumerable.Range(0, (int)Math.Log10(value) + 1) // 常用対数で桁を求め | |
.Select((item, index) => index) // インデックス番号を値に入れて | |
.Select(d => (int)(value / (long)Math.Pow(10,d) % 10)); // その桁の整数値を求める | |
// UIの表示とかにはこのままのほうが扱いやすい | |
Console.WriteLine(String.Join(",", digit)); | |
// 単純に桁毎に配列に分ける場合はReverse()する | |
Console.WriteLine(String.Join(",", digit.Reverse())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment