发表于: 2017-09-25 22:56:53
1 802
一、今天完成的事情
1.完成了一道题。。。
/*01-复杂度2 Maximum Subsequence Sum(25 分) Given a sequence of K integers { N 1 , N 2 , ..., N K }. A continuous subsequence is defined to be { N i , N i+1 , ..., N j } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For example, given sequence { -2, 11, -4, 13, -5, -2 }, its maximum subsequence is { 11, -4, 13 } with the largest sum being 20. Now you are supposed to find the largest sum, together with the first and the last numbers of the maximum subsequence. Input Specification: Each input file contains one test case. Each case occupies two lines. The first line contains a positive integer K (≤10000). The second line contains K numbers, separated by a space. Output Specification: For each test case, output in one line the largest sum, together with the first and the last numbers of the maximum subsequence. The numbers must be separated by one space, but there must be no extra space at the end of a line. In case that the maximum subsequence is not unique, output the one with the smallest indices i and j (as shown by the sample case). If all the K numbers are negative, then its maximum sum is defined to be 0, and you are supposed to output the first and the last numbers of the whole sequence. Sample Input: 10 -10 1 2 3 4 -5 -23 3 7 -21 Sample Output: 10 1 4*///具体实现代码import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int count = in.nextInt(); int[] array = new int[count ]; for(int i = 0; i < count ; i++) { array[i] = in.nextInt(); } int thisSum = 0; int maxSum = -1; int start = 0; int end = 0; int tmp = 0; for (int j = 0; j < count ; j++) { thisSum += array[j]; if(thisSum > maxSum ) { maxSum = thisSum; end = j; start = tmp; } else if(thisSum < 0) { tmp = j + 1; thisSum = 0; } } if(maxSum < 0) { System.out.print(0 + " "+ array[0] +" " +array[count-1]); } else { System.out.print(maxSum +" "+array[start] + " " + array[end]); } } }
PS;代码粘贴不上来。。。。。格式不对。。
2.下午的时候 ,做另一道题,做了一半,,不会 ,所以一个白天就相当于做了一道题,开始怀疑自己。。。。。感觉有点难,,,哎
3.抛弃书籍,在maven官方文档,学习。
重新看了一下maven基础。
重新回顾一下:maven是项目的管理工具,在项目的各个周期中,我们都能用maven来简化一切的步骤,让我们的效率增加,同时也很标准。
还有一些关于Super POM的知识。Super Pom 的位置在apache-maven-3.3.9\lib\maven-model-builder-3.3.9.jar\org\apache\maven\model\pom-4.0.0.xml
4。没了。。。。
二、明天要完成的事
1.决定了,,明天跷课。。。我好好学习。。。。。。。
2.一边刷题 ,一边做修真院的任务!!!
3.明天把一元多项式的乘法和加法。搞明白!(一定完成)
4.学习JDBC基础 mybatis,完成17 18
5.线性结构的三道题。争取做
三、问题
我感觉遇到了问题。。。我现在感觉时间过的好快。。。我学到的东西太少,,,,我不能放弃了,虽然有时候,会怀疑 我到底适不适合编程。不知道别人会不会也这么想,,,
另一个问题就是 我学的浅,浅尝辄止的感觉,所以我希望我能够自己弄清楚一些东西。
四、收获
今天尝试看了官方文档,全英文 感觉也没那么困难,迈出一步,发现没那么困难。
评论