-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray23.java
More file actions
29 lines (27 loc) · 679 Bytes
/
Array23.java
File metadata and controls
29 lines (27 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package array;
/**
* Project Admin -> Husanboy Azamov
* Package Name -> array
* Class Name -> Array23
* Copyright © : 6/23/2022
*/
public class Array23 {
public static void main(String[] args) {
array23(1,4,new int[]{1,2,3,4,5,6,7
});//2,3,4,5
//1+6+7;
}
public static void array23(int k, int l, int[] array) {
int sum=0;
double sol;
for (int i = 0; i < k; i++) {
sum+=array[i];
}
for (int i = l+1; i < array.length; i++) {
sum+=array[i];
}
System.out.println(sum);
sol=(double) sum/(k+(array.length)-l);
System.out.println(sol);
}
}