==挿入ソート==
[[VC++.NET]]{{category ロジック}}
VC++.NET 2005
using namespace System::Collections;
static void insertionSort( array<<String^>>^ ary) {
String^ key;
for (long i=1; i < < ary->>Length; i++) { for (long j=0; j<<i; j++) { if ( ary[i]->>CompareTo(ary[j]) < < 0 ) {
key = ary[i];
for (long k=i; k>>j; k--) {
ary[k] = ary[k-1];
}
}
static void sort( array<<String^>>^ ary ) {
insertionSort(ary);
}
static void print( array<<String^>>^ ary ) {
for (int i=0; i<<ary->>Length; i++) {
Console::WriteLine(ary[i]);
}
}
int main(array<<System::String ^> > ^args)
{
while ( (line = Console::ReadLine()) != nullptr ) {
list->>Add(line);
}
array<<String^>>^ ary = gcnew array<<String^>>(list->>Count); list->>CopyTo(ary, 0);
sort(ary);