עזרה בפיתרון תרגיל...

dikel1

New member
עזרה בפיתרון תרגיל...

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
 

shirbi

New member
ככה לא תקבל תשובה.

קודם כל, תיישר את הקוד לשמאל. דבר שני, תגיד מה ניסית לעשות.
 

dikel1

New member
שוב התרגיל...חסרים לי בו שתי השלמות

התוכנית אמורה לבצע את הפעולה הבאה 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). 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*/ ???
 

vinney

Well-known member
כשאת כותבת הודעה

למטרה יש כפתורים "תחילת קוד" ו"סיום קוד", תשתמשי בהם.
 

dikel1

New member
ניסיון נוסף-עזרה בפיתרון השלמת קוד

התוכנית אמורה לבצע את הפעולה הבאה 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). 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*/ ???
 

dikel1

New member
השלמת קוד

התוכנית אמורה לבצע את הפעולה הבאה 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). 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*/ ???|
 

vinney

Well-known member
זה קשה?

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). 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]; }​
 
למעלה