We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Saturday, May 23, 2015

Short numbers in Array

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace sorting

{
class Program

{
static void Main(string[] args)
{
int a;


int[] s = { 3, 5, 7, 1, 8, 9, 4, 6 };

for (int i = 0; i <= s.Length - 2; i++)

{
for (int j = 0; j <= s.Length - 2; j++)


{
if (s[j] < s[j + 1])


{
a = s[j + 1];
s[j + 1] = s[j];

s[j] = a;

}

}

}
Console.WriteLine("Sort the array");


foreach (int sort in s)

Console.Write(sort + " ");

Console.ReadLine();

}

}

}
 

OUTPUT:

  

No comments: