Results 1 to 7 of 7
Thread: Insert interger
 03012011, 09:49 AM #1Member
 Join Date
 Mar 2011
 Posts
 4
 Rep Power
 0
 03012011, 10:23 AM #2Senior Member
 Join Date
 Jun 2008
 Posts
 2,571
 Rep Power
 9
A for loop with 0 and ++ and then a for loop with length and  ?
 03102011, 12:55 PM #3Member
 Join Date
 Mar 2011
 Posts
 4
 Rep Power
 0
My Coding is Here..
Hi all....
My stage 1 and Stage 2 is ok...but my stage 3 had problem
can anybody help me regarding this....
it must divide by 2 then for stage 3 output [4] 4, [5],2 [6]6 [7]0 not appear. What should i do.
Here i put my coding and Output also.
My Coding
import java.util.Scanner;
import java.lang.Math;
import java.util.Random;
public class block14 {
int N;
protected int m = (int) (Math.log(N) / Math.log(2));
static Random random = new Random();
protected int p= (int) (Math.pow(2,(Math.log(N)/Math.log(2)+1)/2));
int split=N/2;
public static void main(String[] args){
System.out.print("Enter Matrix Size : ");
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
System.out.println("");
int i,j,x,count;
int[] outplane = new int[input];
int[] outplane1 = new int[input];
int stage=1;
int plane=0;
int[] shuffleMatrix = new int[input];
System.out.println("(STAGE "+stage+")");
System.out.println("");
for(i=0; i<input; i++)
{
outplane1[i] = i;
}
shuffleMatrix = shuffler4(input);
for ( i = 0; i < input; i++)
{
System.out.print( "[" + outplane1[i] + "] "+ shuffleMatrix[i]);
System.out.println("");
}
if (input==2)
{
System.out.println("true");
}
else {
int a, b;
int in = input;
System.out.println("");
while(input%2 == 0 && input != 2)
{
for (j =0; j<input; j++)
{
outplane[j] = shuffleMatrix[j]/2;
}
for(j=0; j<input/2; j++)
{
for(i=j+1; i<input/2; i++)
{
if((outplane[j] == outplane[i]))
{
int split1 = outplane1[i];
int split2 = shuffleMatrix[i];
int split3 = outplane[i];
for(int m=i; m<input; m++)
{
if(m==(input1))
{
outplane1[m] = split1;
shuffleMatrix[m] = split2;
outplane[m] = split3;
}
else
{
outplane1[m] = outplane1[m+1];
shuffleMatrix[m] = shuffleMatrix[m+1];
outplane[m] = outplane[m+1];
}
}
}
}
}
stage++;
System.out.println("(STAGE "+stage+")");
System.out.println("");
for ( i = 0; i < input/2; i++)
{
System.out.print( "[" + outplane1[i] + "] "+ shuffleMatrix[i]);
System.out.println("");
}
System.out.println("");
for ( i = input/2; i < input; i++)
{
System.out.print( "[" + outplane1[i] + "] "+ shuffleMatrix[i]);
System.out.println("");
}
System.out.println("");
input/=2;
}
stage++;
System.out.println(" ");
}
}
public static int[] shuffler4(int lens)
{
int[] nums = new int[lens];
for (int i = 0; i < lens; i++)
nums[i] = i;
// shuffle4
for (int i = 0; i < lens; i++) {
int r = (int) (Math.random() * (i+1)); // int between 0 and i
int swap = nums[r];
nums[r] = nums[i];
nums[i] = swap;
}
return nums;
}
}
Last edited by yuslaidi; 03102011 at 01:01 PM.
 03132011, 06:11 AM #4Member
 Join Date
 Mar 2011
 Posts
 4
 Rep Power
 0
Please guys....is dat anybody can help me??
 03142011, 10:29 AM #5Moderator
 Join Date
 Apr 2009
 Posts
 11,755
 Rep Power
 19
Can I ask why this is under the database section?
 03142011, 03:32 PM #6Member
 Join Date
 Mar 2011
 Posts
 4
 Rep Power
 0
 03142011, 03:53 PM #7Moderator
 Join Date
 Apr 2009
 Posts
 11,755
 Rep Power
 19
Similar Threads

convert interger value to binary value
By ahmed80 in forum New To JavaReplies: 6Last Post: 01212011, 11:26 AM 
How to insert large data into database using one insert query
By sandeepsai39 in forum New To JavaReplies: 3Last Post: 02282009, 09:17 AM 
trying to convert an interger to a string
By matpj in forum New To JavaReplies: 12Last Post: 01152009, 10:08 AM 
Help with sql insert
By jmorris in forum New To JavaReplies: 6Last Post: 12022008, 07:05 PM 
SQL Insert Help!!!!
By shaungoater in forum New To JavaReplies: 1Last Post: 06142008, 03:14 AM
Bookmarks