TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
greedy_algorithms::DigitSeparation Class Reference

A class that provides methods to separate the digits of a large positive number. More...

Public Member Functions

 DigitSeparation ()
 Default constructor for the DigitSeparation class.
 
std::vector< std::int64_t > digitSeparationReverseOrder (std::int64_t largeNumber) const
 Implementation of digitSeparationReverseOrder method.
 
std::vector< std::int64_t > digitSeparationForwardOrder (std::int64_t largeNumber) const
 Implementation of digitSeparationForwardOrder method.
 

Detailed Description

A class that provides methods to separate the digits of a large positive number.

Definition at line 35 of file digit_separation.cpp.

Constructor & Destructor Documentation

◆ DigitSeparation()

greedy_algorithms::DigitSeparation::DigitSeparation ( )
inline

Default constructor for the DigitSeparation class.

Definition at line 40 of file digit_separation.cpp.

40{}

Member Function Documentation

◆ digitSeparationForwardOrder()

std::vector< std::int64_t > greedy_algorithms::DigitSeparation::digitSeparationForwardOrder ( std::int64_t largeNumber) const
inline

Implementation of digitSeparationForwardOrder method.

Parameters
largeNumberThe large number to separate digits from.
Returns
A vector of digits in forward order.

Definition at line 68 of file digit_separation.cpp.

69 {
70 std::vector<std::int64_t> result =
71 digitSeparationReverseOrder(largeNumber);
72 std::reverse(result.begin(), result.end());
73 return result;
74 }
std::vector< std::int64_t > digitSeparationReverseOrder(std::int64_t largeNumber) const
Implementation of digitSeparationReverseOrder method.
uint64_t result(uint64_t n)

◆ digitSeparationReverseOrder()

std::vector< std::int64_t > greedy_algorithms::DigitSeparation::digitSeparationReverseOrder ( std::int64_t largeNumber) const
inline

Implementation of digitSeparationReverseOrder method.

Parameters
largeNumberThe large number to separate digits from.
Returns
A vector of digits in reverse order.

Definition at line 48 of file digit_separation.cpp.

49 {
50 std::vector<std::int64_t> result;
51 if (largeNumber != 0) {
52 while (largeNumber != 0) {
53 result.push_back(std::abs(largeNumber % 10));
54 largeNumber /= 10;
55 }
56 } else {
57 result.push_back(0);
58 }
59 return result;
60 }

The documentation for this class was generated from the following file: