Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > Please Help~

Reply
Thread Tools

Please Help~

 
 
patrickAng patrickAng is offline
Junior Member
Join Date: Feb 2010
Posts: 2
 
      02-24-2010
import java.util.Scanner;

public class MDivisionQuadratic_TRY {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] index = new int[10];
int s;

do {
System.out.println("Please enter number to be store: (0 to stop)");
s = scan.nextInt();
int address = s%10;
boolean flag = true;
int address2=0;
int num=1;

int divi=0;

while (flag)
{

if (address >= index.length)
{
while (address-- > 0)
{
if (index[address] == 0)
{
index[address] = s;
System.out.println(s+" -- ("+address+")");
break;
}
else
if (address == 0 && s != 0)
System.out.println ("Array full, enter 0 to stop.");
flag = false;
}
}
else
if (index[address] == 0)
{
index[address] = s;
System.out.println(s+" -- ("+address+")");
flag = false;
}
else
{
/*
* collsion method( quadratic probe)
divi=s/10; // find the offset
address2=(address+divi)%307; // find the new address
//System.out.println("divi :"+divi);// get 918
System.out.println(s+" -- ("+address2+")");
address=address2;
*/

//-------------------------------
// PLEASE SOLVEE
//-----------------------------
address=(address+(num*num));
num++;


}
}// do wile loop collsion method
} while (s != 0);

System.out.println("\n\n-------------------------");
for (int i=0; i<index.length; i++)
System.out.println(i+"-----------"+index[i]);
System.out.println("-------------------------");
}
}

// if fell free, pls do contact me via my msn or hotmail address : (E-Mail Removed)[/email]
 

Last edited by patrickAng; 02-24-2010 at 09:15 AM..
Reply With Quote
 
 
 
 
patrickAng patrickAng is offline
Junior Member
Join Date: Feb 2010
Posts: 2
 
      02-24-2010
i'm trying to store data into the array, when the current[index] is occupied, it will move to another location untill it found a empty [index]

the problem is : it went out of the array size...
 
Reply With Quote
 
 
 
 
secraser secraser is offline
Junior Member
Join Date: Mar 2010
Posts: 1
 
      03-03-2010
I wish you good luck with this problem.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please please please help this guy with his open source java app casioculture@gmail.com Java 4 05-05-2005 08:24 AM
Console profile for Windows app in VC++ - PLEASE PLEASE PLEASE HELP! MuZZy C++ 7 01-07-2005 08:40 PM
Computer problems please please please help Nick Computer Support 0 06-04-2004 08:49 PM
HELP! HELP! PLEASE, PLEASE, PLEASE tpg comcntr Computer Support 11 02-15-2004 06:22 PM
please help... ...me learn C++ please please please :) KK C++ 2 10-14-2003 02:08 PM



Advertisments