public static void main(String[] args) {
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
numbers = Arrays.stream(numbers).map(num -> num*2);
replace(numbers);
Arrays.stream(numbers).forEach(System.out::println);
}
public static void replace(int[] massive) {
int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE, mx = 0, mn = 0;
for(int i = 0; i < massive.length; i++) {
if(massive[i] > max) {
max = massive[i];
mx = i;
if(massive[i] < min) {
min = massive[i];
mn = i;
massive[mn] = max;
massive[mx] = min;
return massive;
а) (11111012 + AF16) : 368
11111012 = 1 ∙ 26 + 1 ∙ 25 + 1 ∙ 24 + 1 ∙ 23 + 1 ∙ 22 + 0 ∙ 21 + 1 ∙ 20 = 64 + 32 + 16 + 8 + 4 + 0 + 1 = 12510
AF16 = 10 ∙ 161 + 15 ∙ 160 = 160 + 15 = 17510
368 = 3 ∙ 81 + 6 ∙ 80 = 24 + 6 = 3010
(125 + 175) : 30 = 300 : 30 = 10
ответ: 10
б) 1258 + 1012 ∙ 2A16 − 1418
1258 = 1 ∙ 82 + 2 ∙ 81 + 5 ∙ 80 = 64 + 16 + 5 = 8510
1012 = 1 ∙ 22 + 0 ∙ 21 + 1 ∙ 20 = 4 + 0 + 1 = 510
2A16 = 2 ∙ 161 + 10 ∙ 160 = 32 + 10 = 4210
1418 = 1 ∙ 82 + 4 ∙ 81 + 1 ∙ 80 = 64 + 32 + 1 = 9710
85 + 5 ∙ 42 − 97 = 85 + 210 − 97 = 198
ответ: 198
public static void main(String[] args) {
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
numbers = Arrays.stream(numbers).map(num -> num*2);
replace(numbers);
Arrays.stream(numbers).forEach(System.out::println);
}
public static void replace(int[] massive) {
int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE, mx = 0, mn = 0;
for(int i = 0; i < massive.length; i++) {
if(massive[i] > max) {
max = massive[i];
mx = i;
}
if(massive[i] < min) {
min = massive[i];
mn = i;
}
}
massive[mn] = max;
massive[mx] = min;
return massive;
}
а) (11111012 + AF16) : 368
11111012 = 1 ∙ 26 + 1 ∙ 25 + 1 ∙ 24 + 1 ∙ 23 + 1 ∙ 22 + 0 ∙ 21 + 1 ∙ 20 = 64 + 32 + 16 + 8 + 4 + 0 + 1 = 12510
AF16 = 10 ∙ 161 + 15 ∙ 160 = 160 + 15 = 17510
368 = 3 ∙ 81 + 6 ∙ 80 = 24 + 6 = 3010
(125 + 175) : 30 = 300 : 30 = 10
ответ: 10
б) 1258 + 1012 ∙ 2A16 − 1418
1258 = 1 ∙ 82 + 2 ∙ 81 + 5 ∙ 80 = 64 + 16 + 5 = 8510
1012 = 1 ∙ 22 + 0 ∙ 21 + 1 ∙ 20 = 4 + 0 + 1 = 510
2A16 = 2 ∙ 161 + 10 ∙ 160 = 32 + 10 = 4210
1418 = 1 ∙ 82 + 4 ∙ 81 + 1 ∙ 80 = 64 + 32 + 1 = 9710
85 + 5 ∙ 42 − 97 = 85 + 210 − 97 = 198
ответ: 198