import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.InputStreamReader;


public class Main {

	static int solln;
	static int sollm;
	static int n = 0;
	static int m = 0;
	static int z = 0;
	static String text;
	static int length;
	public static void main(String[] args) {
		n = readInInt("Geben Sie die Anfangszahl fuer n ein!");
		m = readInInt("Geben Sie die Anfangszahl fuer m ein!");
		solln = readInInt("Geben Sie die Endzahl fuer n ein!");
		sollm = readInInt("Geben Sie die Endzahl fuer m ein!");
		text = "<table border=\"1\"><tr><td>.</td>";
		for (int i = 0; i <= sollm; i++) {
			text += "<th>" + i + "</th>";
		}
		text += "</tr>";
		System.out.println("0___________25__________50__________75_________100 %");
		for (n = 0; n <= solln; n++) {
			text += "\n</tr><tr><th>"+n+"</th>";
			for (m = 0; m <= sollm; m++) {
				if (m > n && n>0) {
					if ((n%2) != (m%2)) {
						int a = (int) ((Math.pow((double) m, 2) - Math.pow((double) n, 2)));
						int b = 2*m*n;
						int c = (int) ((Math.pow((double) m, 2) + Math.pow((double) n, 2)));
						text += "<td>"+a+","+b+","+c+"</td>";
					}
					else {
						text += "<td>.</td>";
					}
				}
				else {
					text += "<td>.</td>";
				}
			}
			/*for (int z = 0; z <= length; z++) {
				System.out.println("\b");
			}*/
			//System.out.flush();
			//length = (n*sollm + "/" + solln*sollm).length();
			while (z < (int)((double)((double)(n*sollm)/(double)(solln*sollm))*50)) {
				System.out.print("=");
				z++;
			}
		}
		text += "</tr></table>";
		
		
		System.out.println("\n100%\n"+"Fertig! Fange an Daten in Datei zu schreiben...");
		try {
	    String dateiName = "C:\\Dokumente und Einstellungen\\Rene\\Desktop\\phytagoraeischeTrippel\\"+sollm+"_"+solln+"_phy.html";
	    FileOutputStream schreibeStrom;
			schreibeStrom = new FileOutputStream(dateiName);
		
	    for (int i=0; i < text.length(); i++){
	      schreibeStrom.write((byte)text.charAt(i));
	    }
	    schreibeStrom.close();
	    System.out.println("Datei ist geschrieben!");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public static int readInInt(String msg) {
	    try {
	    BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ));

	    String inData;

	    System.out.println(msg);
			inData = stdin.readLine();
		return Integer.parseInt(inData);
			
		} catch (Exception e) {
			System.err.println("Bitte nur Zahlen eingeben!");
			return readInInt(msg);
		}
	}
}


