Einzelnen Beitrag anzeigen
Alt 03.03.2002, 18:43   #8
JosefS
Veteran
 
Registriert seit: 07.01.2002
Alter: 44
Beiträge: 268


Standard

probiers mal mit:

Code:
int[] array = new int[16];
int zz, vorhanden = 0;
boolean schonda = false;

while(vorhanden < array.length-1)
{ 
	zz = (int) (Math.random() * 15); 

	for(int i=0; i<=vorhanden; i++)
	{ 
		if(array[i] == zz)
		{ 
			schonda = true; 
			break; 
		} 
	} 

	if(schonda)
	{ 
		System.out.println(zz + " -> ist schon vorhanden"); 
	} 
	else
	{ 
		System.out.println(zz + " -> noch nicht vorhanden"); 
		array[vorhanden] = zz; 
		vorhanden++; 
	}

	schonda = false; 
}
JosefS ist offline   Mit Zitat antworten