📄 manliyouhua.java
字号:
import javax.swing.JOptionPane;
public class manliyouhua{
public static void main(String[] args) {
String LengthString=JOptionPane.showInputDialog(null,"enter the ziduan's length:","Length:",JOptionPane.QUESTION_MESSAGE);
int a=Integer.parseInt(LengthString);
int[] number=new int[a];
for(int b=0;b<a;b++)
{
String NumberString=JOptionPane.showInputDialog(null,"enter the ziduan's worth:","Number:",JOptionPane.QUESTION_MESSAGE);
int c=Integer.parseInt(NumberString);
number[b]=c;
}
String s1=" ";
for(int k=0;k<number.length;k++){
s1=s1+" "+number[k];
}
JOptionPane.showMessageDialog(null,s1,"the ziduan is:",JOptionPane.INFORMATION_MESSAGE);
int i = 0;
int j = 0;
long max2 = MaxSubSum2(number,0,a-1,i,j);
JOptionPane.showMessageDialog(null,max2,"the max ziduanhe",JOptionPane.INFORMATION_MESSAGE);
}
public static long MaxSubSum2(int[] number,int l,int r,int left,int right)
{
int max = 0;
for (int i = l; i <= r; ++i)
{
int sum = 0;
for (int j = i; j <= r; ++j)
{
sum += number[j];
if (sum > max)
{
left = i;
right = j;
max = sum;
}
}
}
return max;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -