yovkovbpfps

Nested LOOP MATRIX

Apr 16th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Matrix {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. int a = Integer.parseInt(scanner.nextLine());
  7. int b = Integer.parseInt(scanner.nextLine());
  8. int c = Integer.parseInt(scanner.nextLine());
  9. int d = Integer.parseInt(scanner.nextLine());
  10.  
  11. for (int i = a; i <= b; i++) {
  12. for (int j = a; j <= b; j++) {
  13. if (i != j) {
  14. for (int k = c; k <= d; k++) {
  15. for (int l = c; l <= d; l++) {
  16. if (k != l) {
  17. if (i + l == j + k){
  18. System.out.printf("%d%d\n", i, j);
  19. System.out.printf("%d%d\n", k, l);
  20. System.out.println();
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment