Skip to content

Commit fe79ecf

Browse files
Add files via upload
1 parent 8a90ae3 commit fe79ecf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Pairsinarray.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
public class Pairsinarray {
3+
public static int getposition(int nums[]) {
4+
int count = 0;
5+
for (int i = 0; i < nums.length; i++) {
6+
int cur = nums[i];
7+
for (int j = 0; j < nums.length; j++) {
8+
System.out.println("(" + cur + "," + nums[j] + ")");
9+
count++;
10+
}
11+
System.out.println();
12+
}
13+
return count; // Added return statement
14+
}
15+
16+
public static void main(String[] args) {
17+
int nums[] = {1, 4, 7, 8, 7, 5, 8};
18+
int result = getposition(nums);
19+
System.out.println("Total pairs: " + result);
20+
}
21+
}

0 commit comments

Comments
 (0)