2 桁の 10 進数を int 配列に変換する必要があります。たとえば、私が数値を持っていると仮定すると、それをwhereと32
に変換したいと思います。int[] a = new int[2]
int[0] = 3
int[1] = 2
1551 次
3 に答える
1
あなたは試すことができます:
int x = 32;
int[] array = { x / 10, x % 10 };
于 2015-02-05T08:07:31.510 に答える
0
これを試して:
int x, temp, i=0, j;
int[] a, b;
//Get the integer first and store in x
//Also allocate the size of a and b with the number of digits that integer has
while(x > 0)
{
temp = x%10;//gives remainder
a[i] = temp;//store that value in array
x = x/10;//to get the remaining digits
}
//the array will have the numbers from last digit
元:
私は x = 322 を持っています
配列 a は { 2, 2, 3 } になります。
//to get the actual array try this
j = a.length;
while(i<j)
{
b[i]=a[j];
i++;
j--;
}
配列 b は { 3, 2, 2 } になります。
于 2015-02-05T08:17:42.477 に答える