java高手帮一下忙,怎么程序就有问题呢?
packagesuanfafenxi3;publicclassfirst{publicvoidmaxSubarray(int[]array,int[]tailarray,...
package suanfafenxi3;
public class first {
public void maxSubarray(int[] array,int[] tailarray,int max)
{ int i,j,k,n=array.length;
for(i=1,tailarray[0]=1;i<n;i++)
{for(j=0,k=0;j<i;j++)
{
if(array[j]<=array[i]&&k<tailarray[j]) k=tailarray[j];
tailarray[i]=k+1;
}
}
int temp;
for(i=0,temp=0;i<n;i++)
{
if(tailarray[i]>temp) temp=tailarray[i];
}
max=temp;
}
public static void main(String[] args) {
int[] array={1,4,7,20,2,11,5,13,6,10};
int[] tailarray={0};
int max=0;
first a=new first();
a.maxSubarray(array, tailarray, max);
System.out.print(max);
}
} 展开
public class first {
public void maxSubarray(int[] array,int[] tailarray,int max)
{ int i,j,k,n=array.length;
for(i=1,tailarray[0]=1;i<n;i++)
{for(j=0,k=0;j<i;j++)
{
if(array[j]<=array[i]&&k<tailarray[j]) k=tailarray[j];
tailarray[i]=k+1;
}
}
int temp;
for(i=0,temp=0;i<n;i++)
{
if(tailarray[i]>temp) temp=tailarray[i];
}
max=temp;
}
public static void main(String[] args) {
int[] array={1,4,7,20,2,11,5,13,6,10};
int[] tailarray={0};
int max=0;
first a=new first();
a.maxSubarray(array, tailarray, max);
System.out.print(max);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询