dongtaiguihua.java

来自「算法分析实验 java实现: 有: 公约数 合并算法 字符排序 快速排序」· Java 代码 · 共 43 行

JAVA
43
字号
import javax.swing.JOptionPane;

public class dongtaiguihua{
public static void main(String[] args)
{
String LengthString=JOptionPane.showInputDialog(null,"pleae inout the zuduan's length","The experice",JOptionPane.QUESTION_MESSAGE);
int Length=Integer.parseInt(LengthString);
float[] ziduan=new float[Length];
for(int m=0;m<Length;m++)
{
String WorthString=JOptionPane.showInputDialog(null,"pleae inout the zuduan's worth","The experice",JOptionPane.QUESTION_MESSAGE);
float Worth=Float.parseFloat(WorthString);
ziduan[m]=Worth;
}
     String s1=" ";
       for(int k=0;k<Length;k++)
        {
          s1=s1+" "+ziduan[k];
        }	  
   JOptionPane.showMessageDialog(null,s1,"输入的字段:",JOptionPane.INFORMATION_MESSAGE);
   
	int max3=max_sub3(ziduan,Length);
   JOptionPane.showMessageDialog(null,max3,":",JOptionPane.INFORMATION_MESSAGE);	
   // max_sub3(ziduan,Length);
}


public static int max_sub3(float a[], int size)
{
     int i,max=0,temp_sum=0;
     for(i=0;i<size;i++)
     {
          temp_sum+=a[i];
          if(temp_sum>max)
               max=temp_sum;
          else if(temp_sum<0)
               temp_sum=0;
     }
    return max;
}


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?