using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i, j, n,temp;
int[] a = new int[10];
Console.Write("Enter the number of elements: ");
n=int.Parse(Console.ReadLine());
Console.Write("Enter the elements");
for(i=1;i<=n;i++)
{
a[i]=int.Parse(Console.ReadLine());
}
for (i = 1; i<=n; i++)
{
for(j=1;j<=n;j++)
if (a[i]<a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
Console.Write("The sorted elements are:");
for(i=1;i<=n;i++)
Console.Write(""+a[i]);
Console.ReadKey();
}
}
}
/*Do leave a comment if you find this useful*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i, j, n,temp;
int[] a = new int[10];
Console.Write("Enter the number of elements: ");
n=int.Parse(Console.ReadLine());
Console.Write("Enter the elements");
for(i=1;i<=n;i++)
{
a[i]=int.Parse(Console.ReadLine());
}
for (i = 1; i<=n; i++)
{
for(j=1;j<=n;j++)
if (a[i]<a[j])
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
Console.Write("The sorted elements are:");
for(i=1;i<=n;i++)
Console.Write(""+a[i]);
Console.ReadKey();
}
}
}
/*Do leave a comment if you find this useful*/
No comments:
Post a Comment