Bubble Shorting Program
using System;
using System.Linq;
namespace BubbleShortingProg
{
internal class Program
{
private static void Main(string[] args)
{
Console.WriteLine("Bubble Shorting");
Console.WriteLine("Enter values with space");
string inputLine = System.Console.ReadLine();
string[] inputLine_arr = inputLine.Split(' ').ToArray();
int[] inputArr = Array.ConvertAll(inputLine_arr, Int32.Parse);
int tempValue = 0;
for (int node = 0; node < inputArr.Length; node++)
{
for (int sort = 0; sort < inputArr.Length - 1; sort++)
{
if (inputArr[sort] > inputArr[sort + 1])
{
tempValue = inputArr[sort + 1];
inputArr[sort + 1] = inputArr[sort];
inputArr[sort] = tempValue;
}
}
}
for (int i = 0; i < inputArr.Length; i++)
Console.Write(inputArr[i] + " ");
Console.ReadKey();
}
}
}
No comments:
Post a Comment