15,897,371 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13736730 (Top 5 by date)
Member 13736730
29-Nov-18 7:38am
View
thanks the code was correct just had put "=" by mistake.
Member 13736730
29-Nov-18 7:34am
View
thanks the code was correct just had put "=" by mistake.
Member 13736730
19-Nov-18 19:15pm
View
thanks for the reply, going witht the 2nd example it does need an iterator after the while loop to run 51 times doesnt it?
Member 13736730
1-May-18 14:42pm
View
The code was in c++ and I was converting it into c# and I’m not good at c# so some code have c++ characteristics
Member 13736730
20-Mar-18 9:45am
View
Deleted
using System;
using System.IO;
namespace ProfitCalculator
{
/// ==============================================================================
public class RangeFinder
{
/// <summary>
/// Performs calculations to find the start and end of the "best" data sequence
/// which has the greatest sum of data values over that sequence.
///
/// <param name="data">the data to be examined
/// <param name="bestStart">the start point found by the search
/// <param name="bestEnd">the end point found by the search
/// <param name="bestTotal">the sum of data values over that range
/// <param name="loops">the number of executions of the inner loop
public static void MaxSum1(double[] data, out int bestStart,
out int bestEnd, out double bestTotal, out int loops)
{
bestTotal = 0;
bestStart = 0;
bestEnd = 0;
loops = 0;
for
(int i = 0; i < data.Length; i++)
{
Console.WriteLine("Value {0}", data[i]);
}
}
public static void MaxSum2(double[] data, out int bestStart,
out int bestEnd, out double bestTotal, out int loops)
{
bestTotal = 0;
bestStart = 0;
bestEnd = 0;
loops = 0;
}
public static void MaxSum3(double[] data, out int bestStart,
out int bestEnd, out double bestTotal, out int loops)
{
bestTotal = 0;
bestStart = 0;
bestEnd = 0;
loops = 0;
}
/// ==============================================================================
/// <summary>
/// Tests the Profits Calculator
///
class Test
{
/// <summary>
/// The main entry point for the application.
///
static void Main()
{
double[] data;
int bestStart, bestEnd;
double bestTotal;
int loops;
/// name of the file and the number of readings
string filename = "week52.txt";
int items = 52;
data = new double[items]; /// create the data array
try
{
TextReader textIn = new StreamReader(filename);
for (int i = 0; i < items; i++) /// input and store the data values
{
string line = textIn.ReadLine();
data[i] = double.Parse(line);
}
textIn.Close();
}
catch
{
Console.WriteLine("File Read Failed");
return;
}
/// ---------------------------------------------------------------------
/// call the process method to find the best profit period
/// ---------------------------------------------------------------------
RangeFinder.MaxSum1(
data, out bestStart, out bestEnd, out bestTotal, out loops);
Console.WriteLine("Start : {0} End : {1} Total {2} Loops {3}",
bestStart, bestEnd, bestTotal, loops);
RangeFinder.MaxSum2(
data, out bestStart, out bestEnd, out bestTotal, out loops);
Console.WriteLine("Start : {0} End : {1} Total {2} Loops {3}",
bestStart, bestEnd, bestTotal, loops);
RangeFinder.MaxSum3(
data, out bestStart, out bestEnd, out bestTotal, out loops);
Console.WriteLine("Start : {0} End : {1} Total {2} Loops {3}",
bestStart, bestEnd, bestTotal, loops);