First, the idea of code
For the first one-dimensional array extension, to increase the Arabesque function, our design idea is to each comparison once the exchange, will first fall into place after the second tune to the first, the third tune to the second, and so on, and so on, and then the experiment one to find the largest subarray and
Second, the Code
Package Com.minirisoft;import java.util.*;p ublic class supermax{public static int Exchange (int arr[],int n) {int t;for ( int j=0;j<n-1;j++) {t=arr[j];arr[j]=arr[j+1];arr[j+1]=t;} return 0;} public static void Main (string[] args) {Scanner sc=new Scanner (system.in); int[] List = new int[10];//The input array is an array that must be defined before an error occurs! int[] arr1 = new int[10];//input array is an array that must be defined before an error occurs! int[] arr = new int[10];//input array is an array that must be defined before an error occurs! SYSTEM.OUT.PRINTLN ("Please input array:"); for (int k=0;k<10;k++) {list[k]=sc.nextint ();} for (int i=0;i<10;i++) {Exchange (list,9), for (int n=0;n<9;n++) {arr1[n]=list[n];for (int m=n;m<9;m++) {arr1[m+ 1]=ARR1[M]+LIST[M+1];} for (int m=n;m<10;m++) {if (Arr1[m]>arr1[n]) {arr1[n]=arr1[m];}} System.out.println ("from" + (n+1) + "The maximum number of sub-arrays of radiation of elements and" +arr1[n]);} arr1[9]=list[9];for (int l=0;l<10;l++) {if (arr1[l]>arr1[0]) {arr1[0]=arr1[l];}} ARR[I]=ARR1[0]; System.out.println ("At this time the maximum number of sub-arrays is" +arr1[0]);} for (int i=0;i<10;i++) {if (arr[i]>arr[0]) {arr[0]=arr[i];}} System.out.println ("Final maximum subarray of the and" +arr[0]);}}
Third, the experimental results
Five, experience
This procedure is the extension of the original program, the main idea is how to make the array position rotation, at first we both have their own implementation method, we have all tried, and finally choose the easy way to implement.
VI. panel members: Yang Guangxin, Guo Jianhao
Pair development four------finding the largest subarray of one-dimensional headless array