Skip to content
小飞侠
  • 首页
  • 小程序
  • uniapp
  • vue
  • APICloud
  • 其他
菜单

博客

  1. 首页>
  2. 其他>
  3. 求一个数组中序列连续数的最大值

求一个数组中序列连续数的最大值

  • Post author:xfxia
  • Post published:2023年9月11日
  • Post category:其他


<?php
$array = array(-2,1,3,9,-4,2,3,5,-3,-4,1,3);
$maxsum = 0;
$thissum = 0;
for ($i=0; $i <count($array) ; $i++) { 
	$thissum+=$array[$i];
	if ($thissum>$maxsum) {
		$maxsum=$thissum;
	}elseif ($thissum<0) {
		$thissum=0;
	}
}
echo $maxsum;
?>

19



版权声明:本文为lzq_csdn_th原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/lzq_csdn_th/article/details/51842434

你可能也喜欢

使用GCC编译STM32工程

在Ubuntu 20.04系统里安装Flatpak软件应用无图标显示问题的解决

JQuery之extend()

Swift 延时执行

Github快速上手笔记(wmt专属)

idea SpringBoot整合shiro 图文详解

armbian 入门知识基础学习

ajax换头像,ajax切换明星头像!

嵌入式项目开发

html2canvas生成图片上传到后台服务器

访问本地localhost时,要求输入用户名和密码的解决方法

插值拟合算法

margin:0 auto无效原因

当618成“抢人大战”,知道“怎么抢”才能“抢得到”

FarPoint.Win.Spread 常规操作

Skywalking简单入门使用

TX2 -cartographer安装

wps 字体对系统无效_“字体”侵权,你是否也中招?

flask的权限管理

组态王中两个if连用必须加上大括号

目录

  • APICloud (3)
  • golang (228)
  • java (8,236)
  • linux (4,002)
  • mysql (2,800)
  • php (1,070)
  • python (5,439)
  • solidity (25)
  • uniapp (235)
  • vue (2,463)
  • 其他 (88,233)
  • 小程序 (801)

文章归档

  • 2023年十二月 (1872)
  • 2023年十一月 (477)
  • 2023年十月 (17371)
  • 2023年九月 (44974)
  • 2023年八月 (26399)
  • 2023年七月 (14793)
  • 2023年六月 (1)
  • 2023年五月 (2186)
  • 2023年四月 (3838)
  • 2023年三月 (1544)
  • 2023年二月 (3)
  • 2023年一月 (4)
  • 2022年十二月 (3)
  • 2022年十一月 (36)
  • 2022年十月 (16)
  • 2022年九月 (8)
  • 2021年九月 (1)
  • 2020年九月 (6)
  • 2020年八月 (5)

标签

Aave (1) cosmos (6) defi (255) flag (27) gitee (1) github (1) golang (234) java (8234) linux命令 (82) List (1) map (1115) mysql (3093) npm (237) tendermint (6) uuid (43) vant (64) vmware (270) 区块链 (63) 合约 (37) 小程序版本更新 (3)
  • 首页
  • 小程序
  • uniapp
  • vue
  • APICloud
  • 其他
Copyright xfxia.com 鲁ICP备19024253号-2
关闭菜单