今天对前天留的测试第二阶段进行了测试

测试代码如下

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class shuzu{
    public static void main(String[] args){
            Scanner sc=new Scanner(System.in);
            System.out.println("输入10个数");
            int num[]=new int[10];
            int sum=0;
            int sum1=0;
            for(int i=0;i<10;i++) {
                num[i]=sc.nextInt();
                if(num[i]>sum) {
                    sum=num[i];
                }
            }
            for(int i=0;i<10;i++) {
                sum1=num[i];
                for(int j=i+1;j<10;j++) {
                    sum1=sum1+num[j];
                    if(sum1>sum) {
                        sum=sum1;
                    }
                }
            }
            System.out.println("最大和为:"+sum);
       }

    static String s="";


//    public static void main(String[] args) throws IOException {
//
//        chansheng();
//        read();
//        String[] rang=s.split("[^(-9--10-9)]");
//        BigInteger value=new BigInteger("0");
//        BigInteger sum=new BigInteger(String.valueOf(rang[0]));
//        for(int i=0;i<rang.length;i++) {
//            int a=value.compareTo(BigInteger.valueOf(0));
//            if(a==0||a==-1) {
//                value=new BigInteger(String.valueOf(rang[i]));
//            }else {
//                value.add(new BigInteger(String.valueOf(rang[i])));
//
//            }
//            if(sum.compareTo(value)==-1) {
//                sum=value;
//            }
//        }
//        System.out.println("最大值为:"+sum);
//    }


    public static String read() throws IOException {
        FileInputStream fis =new FileInputStream("leitianyushishabi.txt");
        BufferedReader br =new BufferedReader(new InputStreamReader(fis));
        String temp=" ";
        while((temp = br.readLine())!=null) {
            s= s+temp +"\n";
        }
        fis.close();
        br.close();

        return s;

    }


    public static void chansheng() throws IOException {
        int n;
        System.out.println("请输入要产生的数量:");
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        File file1=new File("leitianyushishabi.txt");
        FileWriter out=new FileWriter(file1);
        BufferedWriter bw =new BufferedWriter(out);
        for(int i=0;i<n;i++) {
            int ran =(int) ((int) (Math.random()*100000000)-Math.random()*100000000);
            BigInteger a=new BigInteger(String.valueOf(ran));
            bw.write(String.valueOf(a)+" ");
        }
        bw.close();
    }
}