いろいろなテクニック.Nucleo と DISCO-F746 用.

Dependencies:   Array_Matrix mbed

MySort.hpp

Committer:
MikamiUitOpen
Date:
2017-10-15
Revision:
0:bb939e0bc6e2
Child:
1:bbb9f0c3e523

File content as of revision 0:bb939e0bc6e2:

#include "mbed.h"
#include <algorithm>
#include <string>

void MySort()
{
    printf("\r\n\"MySort\" の開始\r\n");

    // 配列を昇順にソートする
    const int N = 6;
    string data0[N] = {"const", "Printf", "Int", "for", "array", "Vector"};
    printf("ソート前:\r\n");
    for (int n=0; n<N; n++)
        printf("    %s\r\n", data0[n].c_str());

    string *data1 = new string[N];
    for (int n=0; n<N; n++) data1[n] = data0[n];
    sort(data1, data1+N); // 配列
    printf("ソート後:\r\n");
    for (int n=0; n<N; n++)
        printf("    %s\r\n", data1[n].c_str());

    printf("\"MySorth\" の終了\r\n");
    delete [] data1;
}

// array, vector を昇順にソートする
// 「array」,「vector」
//array<int,N> ar;
//vector<int> v;
//sort(ar.begin(), ar.end()); // array
//sort(v.begin(), v.end()); // vector