User talk:Rahul0611

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package submatrix;

import com.sun.corba.se.impl.resolver.SplitLocalResolverImpl; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Scanner;

/** * * @author rahul.a */ public class Subsubsub {

static Map map = new HashMap; static int size_r = 0, size_c = 0; static String innString = "", inString = "";

public static void main(String[] args) { List l1 = new ArrayList; System.out.println("Enter the size of row matrix"); Scanner scanner = new Scanner(System.in); size_r = Integer.parseInt(scanner.nextLine); System.out.println("Enter the size of col matrix"); size_c = Integer.parseInt(scanner.nextLine); int[][] matrix = new int[size_r][size_c]; System.out.println("Enter elements of matrix"); for (int i = 0; i < size_r; i++) { for (int j = 0; j < size_c; j++) { matrix[i][j] = Integer.parseInt(scanner.nextLine); }       }        findBigest(matrix); Iterator it = map.entrySet.iterator; while (it.hasNext) { Map.Entry pairs = (Map.Entry) it.next; String h[] = pairs.getKey.toString.split(";"); int pos1 = Integer.parseInt(h[0]); int pos2 = Integer.parseInt(h[1]); String h1[] = pairs.getValue.toString.split(";"); int size1 = 0; int size2 = 0; for (int i = 0; i < h1.length; i++) { size1 = Integer.parseInt(h1[i].charAt(0) + ""); size2 = Integer.parseInt(h1[i].charAt(2) + ""); int sum = 0; for (int j = pos1; j < pos1 + size1; j++) { for (int k = pos2; k < pos2 + size2; k++) { sum = sum + matrix[j][k]; }               }                inString = pos1 + "" + pos2 + ";" + size1 + "X" + size2 + "&" + sum; l1.add(inString); }       }        int temp1 = 0; for (int i = 0; i < l1.size; i++) { String arr[] = ((l1.get(i)).toString).split("&"); int temp = Integer.parseInt(arr[1]); if (temp1 < temp) { temp1 = temp; }       }        String position = ""; String size = ""; for (int i = 0; i < l1.size; i++) { String arr[] = ((l1.get(i)).toString).split("&"); if (temp1 == Integer.parseInt(((l1.get(i)).toString).split("&")[1])) { position = arr[0].toString.split(";")[0]; size = (arr[0].toString.split(";")[1]); }       }        System.out.println("Starting Position :::    " + position + "      of  Size :::    " + size); }

private static void findBigest(int[][] matrix) { for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[matrix.length - 1].length; j++) { //   System.out.println("rows" + matrix.length + "cols" + matrix[matrix.length - 1].length); int a[][] = findpermutations(i, j, matrix); func1(a, i, j); }       }    }

public static int[][] findpermutations(int row, int col, int[][] mat) { int size_row = mat.length - row; int size_col = mat[mat.length - 1].length - col; int mat1[][] = new int[size_row][size_col]; int a = 0; int b = 0; for (int i = row; i < mat.length; i++) { b = 0; for (int j = col; j < mat[mat.length - 1].length; j++) { // System.out.println("a" + a + "b" + b); mat1[a][b] = mat[i][j]; b++; }           a++; }       return mat1; }

private static void func1(int[][] a, int pos1, int pos2) { for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[a.length - 1].length; j++) { innString = innString + (i + 1) + "*" + (j + 1) + ";"; map.put(pos1 + ";" + pos2, innString); }       }        innString = ""; } }