I want to divide an integer into a set of its digits. So for example an input (=score) of 123456 should result in {1,2,3,4,5,6} (=s).
Right now I have this and it works, but is there a better way?
int a = score / 1000000000; score -= a * 1000000000;
int b = score / 100000000; score -= b * 100000000;
int c = score / 10000000; score -= c * 10000000;
int d = score / 1000000; score -= d * 1000000;
int e = score / 100000; score -= e * 100000;
int f = score / 10000; score -= f * 10000;
int g = score / 1000; score -= g * 1000;
int h = score / 100; score -= h * 100;
int i = score / 10; score -= i * 10;
int j = score;
int num = 1;
if (a>0) num = 10;
else if (b>0) num = 9;
else if (c>0) num = 8;
else if (d>0) num = 7;
else if (e>0) num = 6;
else if (f>0) num = 5;
else if (g>0) num = 4;
else if (h>0) num = 3;
else if (i>0) num = 2;
int[] s = null;
switch (num)
{
case 1: s = new int[] {j}; break;
case 2: s = new int[] {i, j}; break;
case 3: s = new int[] {h, i, j}; break;
case 4: s = new int[] {g, h, i, j}; break;
case 5: s = new int[] {f, g, h, i, j}; break;
case 6: s = new int[] {e, f, g, h, i, j}; break;
case 7: s = new int[] {d, e, f, g, h, i, j}; break;
case 8: s = new int[] {c, d, e, f, g, h, i, j}; break;
case 9: s = new int[] {b, c, d, e, f, g, h, i, j}; break;
case 10: s = new int[] {a, b, c, d, e, f, g, h, i, j}; break;
}


