I am getting correct answer but the compiler is showing wrong answer. there is difference in sequence insted of 2 and 3 it is 3 and 2
Wrong answer difference in sequence
@ashutosh2 Bro please share the code in text form or save it on https://ide.codingblocks.com/ and share it with me.
And if you want to have a reference for this question have look at the following code-
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int[]arr=new int [n];
for(int i=0;i<n;i++)
{
arr[i]=scn.nextInt();
}
Arrays.sort(arr);
int target=scn.nextInt();
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(arr[i]+arr[j]==target)
{
System.out.println(arr[i]+" and "+arr[j]);
}
}
}
}
}