fork 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. double vector1[] = {2.3, 4.7, 1.4};
  13. double vector2[] = {1.6, 6.2, 3.5};
  14. double vector3[] = new double[6];
  15. double soma1 = 0, soma2 = 0;
  16.  
  17.  
  18. for (double num : vector1) {
  19. soma1 += num;
  20. }
  21.  
  22. for (double num : vector2) {
  23. soma2 += num;
  24. }
  25.  
  26. if(soma1>soma2){
  27.  
  28. System.arraycopy(vector1, 0, vector3, 0, vector1.length);
  29. System.arraycopy(vector1, 0, vector3, vector1.length, vector2.length);
  30.  
  31. } else {
  32.  
  33. System.arraycopy(vector2, 0, vector3, 0, vector2.length);
  34. System.arraycopy(vector2, 0, vector3, vector2.length, vector1.length);
  35. }
  36.  
  37.  
  38. for (double array : vector3) {
  39. System.out.print(array+" ");
  40. }
  41. }
  42. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
1.6 6.2 3.5 1.6 6.2 3.5