个人作业03

package project;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import java.util.Random;
public class shuzu2 {
    public static void main(String args[])
    {
        Random rd=new Random();
        int sum1[]=new int [5];
        int sum;
        long Array1[][]=new long [5][5];
        long Array[][]=new long[1000000][2];
        int count=0,length=0;
        for(long j=0;j<5;j++)
        for(long k=0;k<5;k++){
        long   l   =   (long)(Math.random()*10);
        String   s   =   ""+l;
        int   i   =   s.length();
        int z;
        if((z=(int) (Math.random()*100))%2==0) {
            s="-"+s;
        }
        Array1[(int)j][(int)k]=Integer.parseInt(s);
        }
        int Max=0;
        for(int m=0;m<5;m++)
        {
            for(int k=0;k<5;k++)
            {
                sum1[k]=0;
            }                           
            for(int j=m;j<5;j++)
            {
                for(int i=0;i<5;i++)
                {
                    sum1[i]+=Array1[i][j];
 
                }                     
                for(int n=0;n<5;n++)
                {
                    sum=0;
                    for(int z=n;z<5;z++)
                    {
                        sum+=sum1[z];
                        if(sum>Max)
                        {
                            Max=sum;
                        }
                    }
                    }
                 
                 
                }
            }
        System.out.println("数组最大值为:"+Max);
        }
    }           

 

posted @ 2019-03-27 21:44  Triassic  阅读(114)  评论(0编辑  收藏  举报