Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter the min/max coordinates of the edge of the rectangle here: ");
- int n = Integer.parseInt(sc.nextLine());
- System.out.print("Enter the minimal area of the generated rectangles: ");
- int m = Integer.parseInt(sc.nextLine());
- int count = 0;
- for(int left = -n;left < n;left++){
- for(int top = -n;top < n;top++){
- for(int right = left+1;right<=n;right++){
- for(int bottom = top+1;bottom<=n;bottom++){
- int area = Math.abs(left - right) * Math.abs(top-bottom);
- if(area >= m){
- System.out.println(String.format("(%d,%d) (%d,%d) => %d",left,top,right,bottom,area));
- count++;
- }
- }
- }
- }
- }
- if(count == 0){
- System.out.println("No");
- }
- }
- }
Add Comment
Please, Sign In to add comment