• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Help me with my program? - Please

YaKuZa

Senior member
The user inputs an int, such as 596
I must compute the following, 5*9*6 = 270
How do I tokenize the original integer? Thanks.
 
in the string library there is a function to parse a string into tokens... but I'm not sure what that is called off hand.. just man the string libraby to find it.
Or you could try something like this

int somefunction()

int foo;
cin >> foo;

int hold;
vector<int> vec;
int m;

while(foo%10 > 9)
{
m++;
} //now you know how many digits you have


int digit=10;

pow(digit,m)
for(int i=0;i<m;i++)
{
vec.push_back(foo%digit);
digit = digit / 10;
}

int total = 1;
for(int i=0;i<m;i++)
{
total *= vec;
}

return total;
}


that might work.. but it's not be tested or anything.... gl
 
Back
Top