עזרה בפיתרון תרגיל...
public static int[] conversionStep(int[] state, int radix) { int[] result = {state[0]/10, state[1] /* 2 */ + state[0] /* 3 */ }; return result; } public static int convertRadix(int n, int radix) { int[] state = { n, 0 }; while (state[0] != 0) state = conversionStep(state, radix); return state[1]; } מה חסר במקום הסימנים בשורה השניה /*2*/ /*3*/ ??? התוכנית אמורה לבצע את הפעולה הבאה For example, convertRadix(23, 16) will return 50, since 23 reversed is 32, but represents 50 in base-16 (3*16^1+2*16^0=50). Written in common notation, 32 base 16 = 50 base 10
public static int[] conversionStep(int[] state, int radix) { int[] result = {state[0]/10, state[1] /* 2 */ + state[0] /* 3 */ }; return result; } public static int convertRadix(int n, int radix) { int[] state = { n, 0 }; while (state[0] != 0) state = conversionStep(state, radix); return state[1]; } מה חסר במקום הסימנים בשורה השניה /*2*/ /*3*/ ??? התוכנית אמורה לבצע את הפעולה הבאה For example, convertRadix(23, 16) will return 50, since 23 reversed is 32, but represents 50 in base-16 (3*16^1+2*16^0=50). Written in common notation, 32 base 16 = 50 base 10