/** * @author monika heiner * @version 1.0 * @date 03.09.2001 * @package dssz.intro * @class WhileDemo1 */ import dssz.io.*; class Euclid_non_robust2 { // GgT zweier Zahlen nach Euclid public static void main(String[] args) { // Vereinbarungen stdin in = new stdin(); int a, b, z1, z2, rest; // Eingabe System.out.println("EUCLID freut sich auf Ihre Anfrage!"); a = in.getInt(" Eingabe der ersten natuerlichen Zahl: "); b = in.getInt(" Eingabe der zweiten natuerlichen Zahl: "); // es werden vernünftige Werte für a und b unterstellt. // Verarbeitung if (a > b) { z1 = a; z2 = b; } else { z2 = a; z1 = b; } // if rest = z1 % z2; while (rest != 0) { z1 = z2; z2 = rest; rest = z1 % z2; } // while // Ausgabe System.out.println("EUCLID: \"GgT von "+a+" und "+b+" ist "+z2+".\""); } // main } // Euclid_non_robust2