Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int najveca(int n) {
- int max = 0;
- while (n > 0) {
- if (max < n % 10)
- max = n % 10;
- n /= 10;
- }
- return max;
- }
- public static int novi(int n) {
- int t = 0;
- int max = najveca(n);
- int izbacenih = 0;
- int stepen = 1;
- while(n > 0) {
- int digit = n % 10;
- n /= 10;
- if (digit == max) {
- if (izbacenih == 0) {
- izbacenih++;
- } else {
- t = digit * stepen + t;
- stepen *= 10;
- }
- } else {
- t = digit * stepen + t;
- stepen *= 10;
- }
- }
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement