Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Find smallest and largest integers in unsorted array
//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) { //Your code goes here int [] arr = new int []{2,5,3,5,6,7,2,1,1,7}; findSmallestAndLargest(arr); } public static void findSmallestAndLargest(int[] a) { int smallest = a[0]; int largest = a[0]; for(int i=1; i< a.Length; i++) { if(a[i]<smallest) smallest=a[i]; if(a[i]>largest) largest=a[i]; } Console.WriteLine(smallest); Console.WriteLine(largest); } } }
run
|
edit
|
history
|
help
0
Lazy XML selection
knapsack
SVSVSV
Use Lock Keyword
Ship! Wall
Best Exam Collection site
Demonstration await Control returned to the Caller
qwerty
Date Diff
Inheritance