+ 1
What and how would I use the bubble sort algorithm using C# to find the maximum value in an array?
3 ответов
+ 3
//c++ algorithm.
int arr[100];
//input values
for ( int i = 0; i < 99 ; i++)
for ( int ii = i+1; ii < 100; ii++)
if (arr[i] > arr[ii])
swap ( arr[i], arr[ii] );
int max = arr [99];
Then translate this code to C#.
+ 1
To find a minimum or maximum?
0
To find the maximum value and sort the list efficiently.