Aug 24, 2016

Container sort [컨테이너값 정렬 시키기]

str                     _TempValue1;
    str                     _TempValue2;
    int                     _i;
    int                     _j;
    container               _containerValue;
    container               _containerSort;
    _containerValue = [1,4,5,2,6,8];
   
    _containerSort = _containerValue;
    for (_i = 1; _i <= conlen(_containerSort); _i++)
    {
        for (_j = _i + 1; _j <= conlen(_containerSort); _j++)
        {
            _TempValue1 = conpeek(_containerSort, _i);
            _TempValue2 = conpeek(_containerSort, _j);
            if (_TempValue1 < _TempValue2)
            {
                _containerSort = condel(_containerSort, _j, 1);
                _containerSort = conins(_containerSort, _j, _TempValue1);
                _containerSort = condel(_containerSort, _i, 1);
                _containerSort = conins(_containerSort, _i, _TempValue2);
            }
        }
    }
    conview(_containerSort);

No comments:

Post a Comment