Help me with my program? - Please

YaKuZa

Senior member
Aug 26, 2000
995
0
0
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.
 

dishawbr

Member
Mar 2, 2002
69
0
0
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