博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
机试题:最大序列和
阅读量:4107 次
发布时间:2019-05-25

本文共 394 字,大约阅读时间需要 1 分钟。

import java.util.Scanner;public class Main {	public static void main(String[] args) {		// TODO Auto-generated method stub		Scanner sc=new Scanner(System.in);		while(sc.hasNext())		{			int n=sc.nextInt();			int []a=new int[n];			for(int i=0;i
max) { max=sum; } if(sum<0) { sum=0; } } System.out.println(max); } }}

这优秀的解法啊~尤其是sum<0 这里

我什么时候才能毫不费力地写出这样的解法呢~~~

转载地址:http://vcssi.baihongyu.com/

你可能感兴趣的文章
MFC框架程序中OnIdle
查看>>
代码编译过程
查看>>
函数调用规范
查看>>
关于VS中静态调用dll的一些问题
查看>>
C++:公有继承、私有继承和保护继承
查看>>
MYSQL问题解决方案:Access denied for user 'root'@'localhost' (using password:YES)
查看>>
MYSQL问题解决方案:安装过程中无法start service...
查看>>
构造函数为什么不能是虚函数?
查看>>
C++:overload, override和overwrite
查看>>
关于C++两个类相互引用的一点思考
查看>>
Windows支持的4种类型的同步对象:临界区、互斥量、事件和信号量
查看>>
Linux异步I/O
查看>>
C++智能指针详解
查看>>
Centos 安装五笔
查看>>
C语言中的复杂声明和定义,以及如何使用typedef进行简化
查看>>
关于const与指针混合使用的助记法
查看>>
关于const int*, int const*以及int *const的区别
查看>>
串口通讯—异步通信方式
查看>>
串口通讯—同步通信方式
查看>>
QQ窗口传代码问题(2010-12-14)
查看>>