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:
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:
Post a Comment