Welcome to oopos's Blog
最大子段和問題:
對於一個序列: -6,9,8,-10,100,-99
其中:最大子段和為:100
子段長度為:10
*/
#include <stdio.h>
#include <stdlib.h>#define MAX 101int main(void)
{
int i,j,k,n,max=0,sum=0;
int sj=0 , sk =0,st=0 ;
int a[MAX]={0} ;
scanf("%d",&n);
for(i=1 ; i<= n ; i++)
scanf("%d",&a[i]);
for(i=1,sj=1
{
if (sum >=0)
sum += a[i] ;
else
{
sum = a[i];
sj = i ;
}
if(sum > max)
{
max = sum ;
st= sj ;
sk = i ;
}
}
printf(
printf("The result is : "); /*輸出最優解*/for(i=st ; i<= sk ; i++)
printf("%d ",a[i]);
printf("");
system("pause");
return0;
}
相關推薦
Welcome to oopos's Blog
/*最大子段和問題:對於一個序列: -6,9,8,-10,100,-99其中:最大子段和為:100 子段長度為:10*/#include <stdio.h>#include <stdlib.h>#define MAX 101int main(void){ int i,j,k,n,
Welcome to JRX2015U43's blog!
【英文題目】 A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integer S (S <
Welcome to yjjr's blog!
T1 yyy點餐 題意 給出長度為nnn的序列,求有所有不同的組合的代價總和(每種組合的代價為該組合內所有數之和) 對於全部資料,有1≤n≤1000000,0≤ai<9982443531\
Welcome to ray's blog home page
在Java中,一個物件在可以被使用之前必須要被正確地初始化,這一點是Java規範規定的。本文試圖對Java如何執行物件的初始化做一個詳細深入地介紹(與物件初始化相同,類在被載入之後也是需要初始化的,本文在最後也會對類的初始化進行介紹,相對於物件初始化來說,類的初始化要相對
Welcome to DaxinPai's Blog
在資料分析中,遇到統計問題的時候,基本可以按照下表來: (圖片來源自網上,出處不詳) 那麼首先我們需要判斷是否是正態分佈(Normal Distribution), 四種方法: 繪製資料的直方圖,看疊加線——這是一種粗略的方法,且不是硬性( ha
Welcome to tikeyc's column
蘋果靜止熱更新,可惜我的是企業APP...(當然有些熱更新已經可以通過蘋果稽核了,比如JSPatch) 最近公司要新增熱修復BUG,其實早之前本人就有簡單實現過,剛好契合公司需求,在此總結一下iOS熱更新實現方式 這個是我根據JSPatch寫的一個Demo:https://github.com/tike
Welcome to Simmel's Garden
看別人的論文時看到利用腳註將冗餘資訊放到頁面腳註位置,使得論文作者區域清爽、簡潔、高階。想要效仿。於是在網路中進行了一番搜尋,發現了一篇博文給了我答案:實現的效果是任意指定作者的標註符號,包括多個作者可
【Welcome to Smile-Huang 's Blog.】This Blog aims to share my experience with you. Please leave comments if you have any thoughts.
This Blog aims to share my experience with you. Please leave comments if you have any thoughts.
Welcome to Smile-Huang 's Blog.
#include<iostream> #include<string> #include<fstream> using namespace std; //字元數目為n的詞項k-gram數目為n+1-k //預定的閾值為0.1 #define threshold 0.1
Welcome to Feng.Chang's Blog
1、檢視當前登入使用者 [[email protected] ~]$ whatis w w (1) - Show who is logged on
welcome to 浩·C's blog
#include <iostream> using namespace std; /* 思路: 注意題中說的“好晶片比壞晶片多”,所以對於每個晶片,可以記錄其他行的晶片對該
Welcome to WindowsCE's World.
因為專案需要,準備學習 WinCE 了。以前一直在弄嵌入式 Linux,突然進入Windows平臺,還真不太適應,許多WinCE的概念與思維與Linux相去甚遠,更談不上 Linux 下開源給人的透明與暢快。 仗著自己在VC上還算“有點”小經
Quinn's blog ! I'm glad to be here!
數學推導 比例縮法填充,滿足最大邊填充,故此,首先找出相對於填充的最大邊 let fromW = from.width let fromH = from.height let toH = to
Welcome to my blog. I hope you can communicate with me.
以上程式碼實現了利用Js獲取裝置螢幕的寬度,並根據螢幕的寬度動態改變根元素html的font-siz屬性的作用。比如說,對於iphone6而言,螢幕尺寸為750,那麼在iPhone6下html的font-size為1px,所以1rem = 1px;對於iPhone5而言,螢幕尺寸為640,那麼在iPhone5
Deploying Facebox to AWS ECS @ Alex Pliutau's Blog
Currently I am building a product on top of face recognition functionality and I am using Facebox with go-sdk as it’s the easiest way to add
o means open. Simple CLI tool to open repository in browser. @ Alex Pliutau's Blog
Here is my small bash function! When you run it from the terminal it opens the GitHub/BitBucket/GitLab page in your browser for the git reposi
How to build Go plugin with data inside @ Alex Pliutau's Blog
Go 1.8 gives us a new tool for creating shared libraries, called plugins! This new plugin buildmode is currently only supported on Linux. But
Different ways to block Go runtime forever @ Alex Pliutau's Blog
The current design of Go’s runtime assumes that the programmer is responsible for detecting when to terminate a goroutine and when to terminat
Transitioning from Engineer to Engineering Manager @ Alex Pliutau's Blog
A couple of months ago I moved from a Team Lead position to being an engineering manager at Wizeline Vietnam on a small sized team. I’ve fou
Migrate blog to AWS’s ec2
My blog had been hosting on Linost since 2013. But recently support staff from Linost noticed me that my site has led CPU usage of the host machine t