Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Maximum profit
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { // Get the maximum profit for stock prices that occur in a day var prices = new Int32[] { 40, 32, 20, 50, 100 }; var max = prices[0]; var min = max; for (var i = 0; i < prices.Length; i++) { var curr = prices[i]; if (curr > max) { max = curr; } if (curr < min) { min = curr; } } Console.WriteLine(String.Format("Maximum profit is: ${0}", max-min)); } } }
run
|
edit
|
history
|
help
0
saira_pr1.c
hello,world
Fórum SO ➡ Merging 2 lists by Name and adding their Values, using LINQ ♦
Delegates
DaysOfYear
Aggregate Exception
Floyd’s Warshall Algorithm
asdxasxasdf
Half Sum
ConcurrentQueue<T>