View Single Post
Old Jul 10th, 2005, 3:26 AM   #1
secrecy230
Newbie
 
Join Date: May 2005
Posts: 11
Rep Power: 0 secrecy230 is on a distinguished road
fill array with unique numbers

fill Array with unique number
i have to construct an array of integers and i have to which will generate six integer values in the range 1 to 45 inclusive. The algorithm must loop until all of the six numbers generated are unique


for now i ahve only be able to do that part>>

import java.util.Random;
class s1_1999
{
private static int[] fillArray(int [] array)
{
Random random = new Random();
for(int row = 0 ; row < array.length ;row++)
{

array[row]=random.nextInt(10);

}


private static boolean compare(int [] testarray)
{
boolean test=false;
int testValue=0;
for(int row = 0; row<testarray.length;row++)
{
for (int i=1 ;i<testarray.length ; i++)
{
if(testarray[row]==testarray[i])
{
test=true;

}

}

return test;

}






public static void main(String []args)
{
int [] inarray=new int[6];

fillArray(inarray);

}



can you help me to complete this java program plz??????????
thanx in
advance
from
andy

Forum: Java Post New Thread
Logged in as secrecy230
Title:

Message:
secrecy230 is offline   Reply With Quote