All pastes #770013 Raw Edit

Etwas

public java v1 · immutable
·published 2007-11-11 20:52 UTC
rendered paste body
public class Lottoziehung {		public static int ueberpruefung(int[] werte){		int ergebnis = -1;		for (int o = 0 ;o < 6;o++){			for (int p = 0 ;p < 6;p++){				if (o == p) {continue;}				if (werte[o]==werte[p])					{ergebnis = p;					break;}}}					return ergebnis;			}							public static void main(String[] args) {						if ( args.length != 6 ){			System.out.println("Bitte genau 6 Zahlen angeben!");			System.exit(0);		}		else{		int tipp[] = new int[6];		tipp[0] = Integer.parseInt(args[0]);		tipp[1] = Integer.parseInt(args[1]);		tipp[2] = Integer.parseInt(args[2]);		tipp[3] = Integer.parseInt(args[3]);		tipp[4] = Integer.parseInt(args[4]);		tipp[5] = Integer.parseInt(args[5]);				int ergebnis;		ergebnis = ueberpruefung(tipp);		if (ergebnis != -1)			{ergebnis++;			System.out.println("Doppelter Wert an Stelle"+ ergebnis);			System.exit(0);}									for (int i=0;i < 6;i++ )				if (tipp[i] < 1 || tipp[i] > 49)				{System.out.println("Bitte nur Werte von 1 und 49 angeben!");				System.exit(0);				}				{					int ziehung[] = new int[6];					ziehung[0] = (int)(Math.random()*49.0) + 1;					ziehung[1] = (int)(Math.random()*49.0) + 1;					ziehung[2] = (int)(Math.random()*49.0) + 1;					ziehung[3] = (int)(Math.random()*49.0) + 1;					ziehung[4] = (int)(Math.random()*49.0) + 1;					ziehung[5] = (int)(Math.random()*49.0) + 1;										ergebnis = ueberpruefung(ziehung);					while (ergebnis != -1)					{ziehung[0] = (int)(Math.random()*49.0) + 1;					ziehung[1] = (int)(Math.random()*49.0) + 1;					ziehung[2] = (int)(Math.random()*49.0) + 1;					ziehung[3] = (int)(Math.random()*49.0) + 1;					ziehung[4] = (int)(Math.random()*49.0) + 1;					ziehung[5] = (int)(Math.random()*49.0) + 1;					ergebnis = ueberpruefung(ziehung);}										System.out.println("Ihre Zahlen: " + tipp[0] + " " + tipp[1] + " " + tipp[2] + " " + tipp[3] + " " + tipp[4] + " "+ tipp[5]);					System.out.println("Gezogene Zahlen: " + ziehung[0] + " " + ziehung[1] + " " + ziehung[2] + " " + ziehung[3] + " " + ziehung[4] + " "+ ziehung[5]);                                                                     					int treffer = 0;					for (int o = 0 ;o < 6;o++){						for (int p = o ;p < 6;p++){							if (tipp[o] == ziehung[p]){								treffer++;}						}					}					System.out.println("Sie haben " + treffer + " Treffer!");																							}								}}}