import org.junit.Test; /** * 题目: 一个数组a,长度n,划分为和相等的m个子数组,求m的最大值? * case:a=[2,4,3,1,1,1,3,6,1,1,1,3,9,1,1,1] * 答案:m=3 [2,4,3] [9] [3,6] */ public class test1 { public int getMax(int[] a){ int max=0,sum=0,num_max=0; for (int i=0;i<a.length>num_max){ num_max=a[i]; } } for (int i=0;i<a.length>max){ max=i; } } } } return max; } @Test public void test(){ int[] a=new int[]{3,7,2,4,5,6,9}; int b=getMax(a); System.out.println("最大值b:"+b); } }</a.length></a.length>