今天针对与昨天的上课测试
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); int[] list1 = new int[1000000]; int n = cin.nextInt(); for (int i = 0; i < 10; i++) { list1[i] = cin.nextInt(); } int[] list2 = new int[1000000]; int[] list3 = new int[1000000]; list2[0] = list1[0]; for (int i = 1; i < n; i++) { list2[i] = list2[i - 1] + list1[i]; } int m = cin.nextInt(); for (int i = 0; i < n - m; i++) { if (i == 0) list3[i] = list2[m - 1]; list3[i] = list2[i + m - 1] - list2[i]; } int max = list3[0]; for (int i = 0; i < list3.length; i++) { if (list3[i] > max) max = list3[i]; } System.out.println(max); } }
代码做了具体的理解,代码如下! 标签:总结,int,max,list1,list3,list2,new From: https://www.cnblogs.com/wangzelin/p/17189656.html