Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Podtablice {
- public static Scanner inScan = new Scanner(System.in);
- public static int tab[][];
- public static void makeTab(){
- int n=inScan.nextInt();
- int m=inScan.nextInt();
- tab=new int[n][m];
- for(int i=0;i<n;i++){
- for(int j=0;j<m;j++){
- tab[i][j]=inScan.nextInt(); //moja podtablica
- }
- }
- }
- public static int tabGreatestSum() {
- int max=0;
- int temp;
- for(int j=0;j<tab.length;j++){
- for(int i=0;i<=j;i++){
- for(int l=0;l<tab[0].length;l++){
- for(int k=0;k<=l;k++){
- temp=s(i,j,k,l);
- if(temp>max){
- max=temp;
- }
- //System.out.println(i+""+j+""+k+""+l+""+temp);
- }
- }
- }
- }
- return max;
- }
- private static int s(int i, int j, int k, int l) {
- // TODO Auto-generated method stub
- int temp=0;
- //System.out.println(i+""+j+""+k+""+l+""+temp);
- while(i<=j){
- int kk=k;
- while(kk<=l){
- temp+=tab[i][kk];
- kk++;
- }
- i++;
- }
- //System.out.println(i+""+j+""+k+""+l+"");
- return temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement