fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. //code
  14. int input=561;
  15. Ideone solution=new Ideone();
  16. System.out.println(solution.arrayPairs(input));
  17. }
  18. String arrayPairs(int input){
  19. String retValue="";
  20. int element=input;
  21. int arr[]={1,2,8,9,3,4,5,6,7,10};
  22. int count=0;
  23. for(int i=0; i<arr.length; i++){
  24. if(element==arr[i]){
  25. System.out.println("First loop element at i : " +arr[i]);
  26. retValue = "Yes";
  27. return retValue;
  28. }
  29. for(int j=i+1; j<arr.length-i; j++){
  30. if(element==arr[i]+arr[j])
  31. System.out.println("Elements at i and j : " +arr[i] + ", " +arr[j]);
  32. count++;
  33. }
  34. }
  35. if(count > 0)
  36. retValue = "Yes";
  37. else if(count==0)
  38. retValue ="No";
  39. return retValue;
  40.  
  41. }
  42. }
  43.  
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
Yes