Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.Math;
- public class ShuffleTest {
- public static void main(String[] args){
- int N = Integer.parseInt(args[0]);//number of shuffles
- int M = Integer.parseInt(args[1]);//array size
- int[] mArray = new int[M];
- int[][] mMatrix=new int[M][M];
- for(int i=0;i<N;i++){ //Outer Shuffle Loop
- for(int z=1;z<=M;z++){ //initialize loop, z is a counter
- mArray[z-1]=z;
- //System.out.print(mArray[z-1]); //Verify initialization
- }
- System.out.print(" ");
- for(int j=0;j<M;j++){//shuffle loop
- int numCount = 0;
- int r = 1+(int)(Math.random()*(M-1));
- int t = mArray[j];
- mArray[j] = mArray[r];
- mArray[r]=t;
- System.out.print(mArray[j]);
- if((mArray[j])==j+1){//conditional for
- // mMatrix[i][j]=(mMatrix[i][j]+1);
- }
- }
- System.out.print("\n");
- }
- System.out.print("\n");
- for(int i=0;i<M;i++){
- for(int j=0;j<M;j++)
- System.out.print(mMatrix[i][j]);
- System.out.print("\n");
- }
- }
- }
Add Comment
Please, Sign In to add comment