/* Date:29/10/2008 Author: Deepak Majeti report bugs to: mdeepak@cse.iitk.ac.in */ // 3. Create an array B whose length is read from command line and then fill its // entries with 0 and 1 randomly. Create an array A of size 5 and fill its entries with 0 and // 1 randomly. We say that array A matches B at location i if // A[0] = B[i], A[1] = B[i + 1], A[2] = B[i + 2], A[3] = B[i + 3], A[4] = B[i + 4] // Print all indices i of B, where A gets matched. Execute your program for various size of // array B to find the approximate length of B for which there is at least one match of A ? class ArrayMatch{ public static void main(String args[]){ int A[]=null; int B[]=null; int arraySize=0; try{ arraySize=Integer.parseInt(args[0]); }catch(Exception e){ System.out.println("Please enter and integer(array size) as argument"); System.exit(0); } A=new int[arraySize]; B=new int[arraySize]; //fill the array randomly using numbers between 0-99 and print them System.out.print("Array B is\nB=["); for(int i=0;i