You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Delegate
|
|
|
|
|
{
|
|
|
|
|
class InterB
|
|
|
|
|
{
|
|
|
|
|
public delegate int CompareDelegate(int i1, int i2);
|
|
|
|
|
|
|
|
|
|
public static void Sort(int[] arr, CompareDelegate comp)
|
|
|
|
|
{
|
|
|
|
|
if (arr.Length < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("함수 Prototype: " + comp.Method);
|
|
|
|
|
|
|
|
|
|
int ret;
|
|
|
|
|
for (int i = 0; i < arr.Length - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = i + 1; j < arr.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
ret = comp(arr[i], arr[j]);
|
|
|
|
|
if (ret == -1)
|
|
|
|
|
{
|
|
|
|
|
int tmp = arr[j];
|
|
|
|
|
arr[j] = arr[i];
|
|
|
|
|
arr[i] = tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Show(arr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void Show(int[] arr)
|
|
|
|
|
{
|
|
|
|
|
foreach (int i in arr)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(i + " ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|