-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArray10.java
More file actions
26 lines (21 loc) · 722 Bytes
/
Array10.java
File metadata and controls
26 lines (21 loc) · 722 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
package array;
public class Array10 {
public static void main(String[] args) {
// int[] arr = new int[10];
int[] arr = {10, 13, 26, 21, 19, 1, 2, 8, 14, 19};
solution(arr);
}
// 10 13 26 21 19 1 2 8 14 19
// 10 26 2 8 14 19 1 19 21 13
public static void solution(int[] array) {
// faqat juftlari. Indexlari o'sish tartibida
for (int i = 0; i < array.length; i++) {
if (array[i] % 2 == 0) System.out.print(array[i] + "\t");
}
// faqat taqlari. Indexlari kamayish tartibida
for (int i = array.length - 1; i >= 0; i--) {
if (array[i] % 2 == 1)
System.out.print(array[i] + "\t");
}
}
}