/* * Solution Template for A Mindbending Scenario * * This file is provided to assist with reading and writing of the input * files for the problem. You may modify this file however you wish, or * you may choose not to use this file at all. */ import java.io.*; class Solution { private static int r1_x1; private static int r1_y1; private static int r1_x2; private static int r1_y2; private static int r2_x1; private static int r2_y1; private static int r2_x2; private static int r2_y2; private static int answer; /* * Read the next token from the input file. * Tokens are separated by whitespace, i.e., spaces, tabs and newlines. * If end-of-file is reached then an empty string is returned. */ private static String readToken(BufferedReader in) throws IOException { StringBuffer ans = new StringBuffer(); int next; /* Skip any initial whitespace. */ next = in.read(); while (next >= 0 && Character.isWhitespace((char)next)) next = in.read(); /* Read the following token. */ while (next >= 0 && ! Character.isWhitespace((char)next)) { ans.append((char)next); next = in.read(); } return ans.toString(); } public static void main(String[] args) throws IOException { /* Open the input and output files. */ BufferedReader input_file = new BufferedReader(new FileReader( "bendin.txt")); BufferedWriter output_file = new BufferedWriter(new FileWriter( "bendout.txt")); /* Read the values from the input file. */ r1_x1 = Integer.parseInt(readToken(input_file)); r1_y1 = Integer.parseInt(readToken(input_file)); r1_x2 = Integer.parseInt(readToken(input_file)); r1_y2 = Integer.parseInt(readToken(input_file)); r2_x1 = Integer.parseInt(readToken(input_file)); r2_y1 = Integer.parseInt(readToken(input_file)); r2_x2 = Integer.parseInt(readToken(input_file)); r2_y2 = Integer.parseInt(readToken(input_file)); /* * TODO: This is where you should compute the answer and store it into * the variable answer. */ /* Write the answer to the output file. */ output_file.write(answer + "\n"); /* Finally, close the input/output files. */ input_file.close(); output_file.close(); } }