Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Second minor int
//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.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { var x = new []{6, 3, 4, 1, 2, 5}; int min1 = int.MaxValue, min2 = int.MaxValue; for(var i = 0; i < x.Count(); i++) { if(x[i] < min1){ if(min1 < min2) min2 = min1; min1 = x[i]; } else if(x[i] < min2) { if(min2 < min1) min1 = min2; min2 = x[i]; } } Console.WriteLine(min1 + ", " + min2); min1 = int.MaxValue; min2 = int.MaxValue; for(var i = 0; i < x.Count(); i++) { if(x[i] < min1 || x[i] < min2){ if(min1 < min2) min2 = x[i]; else min1 = x[i]; } } Console.WriteLine(min1 + ", " + min2); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Square Integer Matrix
a
Escape's Vanity Fair (Malformed \p {X} character escape)
Events
Call Class Methods with Interface
caleb
Hello World!
Planet-D v.0.6
Lambda Expression
page 2
stackse - search stackoverflow differently
Please log in to post a comment.