Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Kadane’s Algorithm 1D on pascal

pascal

Best Answer WingedPanther73, 19 June 2014 - 09:54 AM

C++ uses {} instead of Begin End;. It uses = instead of :=. Most of the rest is very similar to Delphi. Think of a vector as an array.

Go to the full post


This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1 phananhtuan

phananhtuan

    CC Newcomer

  • Member
  • PipPip
  • 21 posts

Posted 18 June 2014 - 06:29 AM

I want to know kadane's algorithm because I have a maximum subarray problem

,http://en.wikipedia....ubarray_problem

but I dont understand pefectly. Can someone help me, and how to code on pascal

 



#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 18 June 2014 - 08:20 AM

You should be able to translate the C++ code provided fairly easily. How far have you gotten, and we can help you finish up the details.


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 Vaielab

Vaielab

    Programming God

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1382 posts

Posted 18 June 2014 - 09:07 AM

I try to find some pseudo code for you with google, and the first result give me an other post on codecall

http://forum.codecal...rray-algorithm/

Hope this help


You can now stalk me on linkedin: http://ca.linkedin.c...elle/24/b44/88/ !


#4 phananhtuan

phananhtuan

    CC Newcomer

  • Member
  • PipPip
  • 21 posts

Posted 18 June 2014 - 04:31 PM

You should be able to translate the C++ code provided fairly easily. How far have you gotten, and we can help you finish up the details.

but I dont know about C :biggrin:

 

I try to find some pseudo code for you with google, and the first result give me an other post on codecall

http://forum.codecal...rray-algorithm/

Hope this help

i dont understand, how it work?

pseudo code:


MaxTotal = 0 <=== if all values are positive

foreach subarray in yourarray
{
currentTotal = 0

foreach item in subarray
{
currentTotal = currentTotal + item
}

if currentTotal > MaxTotal
MaxTotal = currentTotal
}

print maxtotal 



#5 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 19 June 2014 - 09:54 AM   Best Answer

C++ uses {} instead of Begin End;. It uses = instead of :=. Most of the rest is very similar to Delphi. Think of a vector as an array.


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#6 phananhtuan

phananhtuan

    CC Newcomer

  • Member
  • PipPip
  • 21 posts

Posted 19 June 2014 - 06:22 PM

C++ uses {} instead of Begin End;. It uses = instead of :=. Most of the rest is very similar to Delphi. Think of a vector as an array.

thank you, i have solved this solution