「選択ソート」の版間の差分

削除された内容 追加された内容
25行目:
swap(data[I], data[min])
end for
</source>
 
===C#での実装例===
<source lang = "text">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace SelectionSort
{
class Program
{
static void Main(string[] args)
{
int temp;
Console.WriteLine("This is a quick sort program written by me : Som Rai");
Console.Write("Enter the number of data you want to sort : ");
int dataNumber = Convert.ToInt32(Console.ReadLine());
int[] Array = new int[dataNumber];
Console.WriteLine("\n");
 
for (int i = 0; i < dataNumber; i++)
{
Console.Write("Enter Number [" + (i + 1) + "] data : ");
Array[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("\n");
foreach (int a in Array)
Console.Write(a + " ");
 
for(int i = 0; i < Array.Length; i++)
{
for(int j = i + 1; j < Array.Length; j++)
{
if(Array[j] < Array[i])
{
temp = Array[i];
Array[i] = Array[j];
Array[j] = temp;
}
}
}
Console.WriteLine("\n");
Console.WriteLine("Sorted Data : ");
foreach (int n in Array)
Console.Write(n + " ");
Console.ReadKey();
}
}
}
</source>