Abdullah047

swap

Nov 18th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1.  
  2. package array;
  3. import java.util.Scanner;
  4. public class Array {
  5.  
  6. public static void main(String[] args) {
  7. Scanner sc=new Scanner(System.in);
  8. int AR1[]=new int[5];
  9. int AR2[]=new int[5];
  10. int AR3[]=new int[5];
  11. int i;
  12. for(i=0;i<AR1.length;i++ ){
  13. System.out.println("ARRAY#1 =");
  14. int q=sc.nextInt();
  15. AR1[i]=q;
  16. }
  17. for(i=0;i<AR2.length;i++){
  18. System.out.println("ARRAY#2=");
  19. int w=sc.nextInt();
  20. AR2[i]=w;
  21. }
  22.  
  23. for(i=0;i<AR1.length;i++){
  24. AR2[i]= AR3[i];
  25. AR1[i]=AR2[i];
  26. AR2[i]=AR3[i];
  27. }
  28. for(i=0;i<AR2.length;i++){
  29. System.out.println(AR1[i]+" "+AR2[i]);
  30. }
  31. }
  32.  
  33. }
Add Comment
Please, Sign In to add comment