Repository: TheAlgorithms/C-Plus-Plus
File: greedy_algorithms/digit_separation.cpp (C++)

Code before:
         */
        std::vector<std::int64_t> digitSeparationForwardOrder(
            std::int64_t largeNumber) const;
    };

    /**
     * @brief Implementation of digitSeparationReverseOrder method.
     *
     * @param largeNumber The large number to separate digits from.
     * @return A vector of digits in reverse order.
     */
    std::vector<std::int64_t> DigitSeparation::digitSeparationReverseOrder(
        std::int64_t largeNumber) const {
        std::vector<std::int64_t> result;
        if (largeNumber != 0) {
            while (largeNumber != 0) {
                result.push_back(std::abs(largeNumber % 10));
                largeNumber /= 10;
            }
        } else {
            result.push_back(0);
        }
        return result;
    }

    /**
     * @brief Implementation of digitSeparationForwardOrder method.
     *
     * @param largeNumber The large number to separate digits from.
     * @return A vector of digits in forward order.
     */
    std::vector<std::int64_t> DigitSeparation::digitSeparationForwardOrder(
        std::int64_t largeNumber) const {
        std::vector<std::int64_t> result = digitSeparationReverseOrder(largeNumber);
        std::reverse(result.begin(), result.end());
        return result;
    }
}

int main() {
    greedy_algorithms::DigitSeparation ds;

    // Test case: Positive number
    std::int64_t number = 1234567890;
    std::vector<std::int64_t> expectedReverse = {0, 9, 8, 7, 6, 5, 4, 3, 2, 1};
    std::vector<std::int64_t> expectedForward = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};

    // Testing reverse order
    std::vector<std::int64_t> reverseOrder = ds.digitSeparationReverseOrder(number);
    assert(reverseOrder == expectedReverse);


Review comment (suggestion):
```suggestion

/**
 * @brief main function
 * @return 0 on sucessful exit
```

Code after:
        if (largeNumber != 0) {
            while (largeNumber != 0) {
                result.push_back(std::abs(largeNumber % 10));
                largeNumber /= 10;
            }
        } else {
            result.push_back(0);
        }
        return result;
    }

    /**
     * @brief Implementation of digitSeparationForwardOrder method.
     *
     * @param largeNumber The large number to separate digits from.
     * @return A vector of digits in forward order.
     */
    std::vector<std::int64_t> digitSeparationForwardOrder(
        std::int64_t largeNumber) const {
        std::vector<std::int64_t> result =
            digitSeparationReverseOrder(largeNumber);
        std::reverse(result.begin(), result.end());
        return result;
    }
};

}  // namespace greedy_algorithms

/**
 * @brief self test implementation
 * @return void
 */
static void tests() {
    greedy_algorithms::DigitSeparation ds;

    // Test case: Positive number
    std::int64_t number = 1234567890;
    std::vector<std::int64_t> expectedReverse = {0, 9, 8, 7, 6, 5, 4, 3, 2, 1};
    std::vector<std::int64_t> expectedForward = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
    std::vector<std::int64_t> reverseOrder =
        ds.digitSeparationReverseOrder(number);
    assert(reverseOrder == expectedReverse);
    std::vector<std::int64_t> forwardOrder =
        ds.digitSeparationForwardOrder(number);
    assert(forwardOrder == expectedForward);

    // Test case: Single digit number
    number = 5;
    expectedReverse = {5};
    expectedForward = {5};
    reverseOrder = ds.digitSeparationReverseOrder(number);