http://www.flashflashrevolution.com/...viewforum&f=49
Use it well.
-Chardish
Warning: Undefined array key "birthday_search" in phar://.../vb/vb.phar/api/user.php on line 2 Warning: Undefined array key "joindate" in phar://.../vb/vb.phar/api/user.php on line 2 Warning: Undefined array key "posts" in phar://.../vb/vb.phar/api/user.php on line 2 Warning: Undefined array key "posts" in phar://.../vb/vb.phar/api/user.php on line 2 Warning: Undefined array key "userid" in phar://.../vb/vb.phar/api/user.php on line 2 Warning: Undefined array key "userid" in phar://.../vb/vb.phar/api/user.php on line 2 Warning: Undefined array key "privacy_options" in phar://.../vb/vb.phar/api/user.php on line 2 Warning: Undefined array key "userid" in phar://.../vb/vb.phar/library/user.php on line 7 Warning: Undefined array key "userid" in phar://.../vb/vb.phar/library/user.php on line 2 Warning: Undefined array key "lastactivity" in phar://.../vb/vb.phar/library/user.php on line 2




for(int i = 0; i < str.length; i++)
{
if(max==0)
break;
int x = Integer.parseInt(str[i]);
if (x == max)
{ //Stops the max value from entering the stack
//addition phase and just outputs it.
for(int l=0;l<str.length; l++)
while (x==max)
{
if (out[l++]==null)
{
out[l]=""+max;
Print(max+" has been moved to the output array.");
max--;
}
else
continue;
}
}
else
{
if (first==0) //puts the first number straight onto the
//stack assuming it is not the max.
{
first=1;
stacks[0].push(new Integer(x));
Print(x+" has been added to HT #1");
}
else
{
int div, store=str.length, index=0;
for (int y=0; y < str.length; y++)
{
if(stacks[y].isEmpty())
{ //if a stack space is empty, put a "0" there so the
//comparison later will read it as an available slot.
stacks[y].push(new Integer(0));
y--;
continue;
}
if (!stacks[y].isEmpty())
{
Integer inte = (Integer)stacks[y].peek();
int q = inte.intValue();
if (x>q)
{ //if my new value is bigger than the value
//at the top of the current stack...
for(int r = 0; r < str.length; r++)
if (!stacks[r].isEmpty())
{
Integer inte2 = (Integer)stacks[r].peek();
val = inte2.intValue();
div = x-val;
if (store > div && div > 0)
{ // take the index of the one that has
//the closest value to x.
store = div;
index=r;
}
}
stacks[index].push(new Integer(x));
Print(x+" has been added to HT #"+(index+1));
}
//Check again until there are no more
//stacks with data in them.
else if (!stacks[y+1].isEmpty())
continue;
//if this has failed, put it on a new one.
else
for(int r = 0; r < str.length; r++)
if (stacks[r].isEmpty())
{
stacks[r].push(new Integer(x));
Print(x+" has been added to HT #"+(r+1));
break;
}
break;
}
}
}
}

Comment