1) Create array with the words that will be uses up to one million.
ex: one , two , three ... , twenty , thirty , .... , hundred , thousand , million
*if they are in order hundred is index 27 , thousand index 28 , million index 29
2) create a function and a vector inside of it like *vector if it is a for loop* if it is not a for loop use a string inplace of my vector
1 2 3 4
|
void number_to_word( unsigned long &number )
{
std::vector<std::string> number( 0 );
}
|
3)
iterate through the numbers
1 2 3 4
|
for( auto i( 0 ); i < 1000; ++i )
{
auto temp( i + 1 ); //makes life easier
}
|
or just use the number you are actually using.
1 2
|
number_to_word( number );
number_to_word( ... ){ auto temp( number ); }
|
4) use an if statement for > 999,999,999 , > 1000 , > 20.
5) ON the first if statement that is *true you want to do something like
number.push_back( words_array[ temp / /*1e6, 1e3 , 1e2 , 1e1*/ - 1 ] + temp[ words_array[ /*position for 1e6 , 1e3 , 1e3 , 1e1 */ ];
temp %= /* 1e6 , 1e3 , 1e2 , 1e1 */
on the if statements after that you want to do something like
//if it is in a loop
numbers[ i ] += ... /* next info for the number */
otherwise
numbers += /*next info for the number
*true means you have to have another if statement inside of that one seeing if it the original value is greater than the current value.