-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraySets.java
More file actions
29 lines (27 loc) · 811 Bytes
/
ArraySets.java
File metadata and controls
29 lines (27 loc) · 811 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 Codes;
import java.util.Scanner;
public class ArraySets {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int size=sc.nextInt();
int[] array=new int[size];
for (int i=0;i<size;i++){
array[i]=sc.nextInt();
}
int choice=sc.nextInt();
if (choice>size)
System.out.println("not possible");
else {
System.out.print("[");
for (int i = 0; i < size; i=i+2) {
for (int j=i+1;j<size;j=j+2) {
if (size % choice == 0) {
System.out.print("("+array[i]+", "+array[j]+"), ");
break;
}
}
}
System.out.print("]");
}
}
}