{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec17+18

# digits int differenceofdigits valueofmaxdigit

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: dex != digits) { int difference_of_digits = value_of_max_digit - digit_at_MSI; int lower_power = Power_of_Ten(max_digit_index-1); new_n = n + (power-lower_power)*difference_of_digits; } return new_n; } 14 The method Max Perm(int n) public static int Max_Perm(int n) { int upper_n; int lower_n; int digits = Num_of_Digits(n); int power= Power_of_Ten(digits); for(int i = digits; i>1; i =i-1) { upper_n= n/power; lower_n= n%power; lower_n= Permutation_with_Max_Digit_at_MSI(lower_n,i); n = upper_n*power+ lower_n; power = power/10; } return n; } 15 P : Computing Max Perm for an integer P : MaxPerm(n) Q: Num_of_Digits(m) Power_of_Ten(i) Perm_with_Largest_Digit_at_MSI(n) Max_Digit_Index(n,digits) 16 Value_of_Digit_at_Index(n,index) II : Common Steps in Problem Solving 1. Und...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online