using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrayAsscendingOrder
{
class Program
{
static void Main(string[] surat)
{
int[] a = new int[10];
int t, i, j;
for (i = 0; i < 5; i++)
a[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Array Element");
for (i = 0; i < 5; i++)
Console.WriteLine(a[i]);
Console.WriteLine("Array After Sorting");
for (i = 0; i < 5; i++)
{
for (j = 0; j < i; j++)
{
if (a[i] < a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
for (i = 0; i < 5; i++)
{
Console.WriteLine(a[i]);
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ArrayAsscendingOrder
{
class Program
{
static void Main(string[] surat)
{
int[] a = new int[10];
int t, i, j;
for (i = 0; i < 5; i++)
a[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Array Element");
for (i = 0; i < 5; i++)
Console.WriteLine(a[i]);
Console.WriteLine("Array After Sorting");
for (i = 0; i < 5; i++)
{
for (j = 0; j < i; j++)
{
if (a[i] < a[j])
{
t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
for (i = 0; i < 5; i++)
{
Console.WriteLine(a[i]);
}
Console.ReadLine();
}
}
}
Output:
No comments:
Post a Comment