Apr 25, 2012 at 1:27pm UTC
Can i return the value of a linked list as 1 integer?
for example: ->5->8->3 represented as a decimal number 583
where it is equal 1 integer NOT 3 integers beside each others.
if yes how please?
Apr 25, 2012 at 8:25pm UTC
@coder777 thanks man. but your code adds the linked list values, and i wanna return the whole linked list values as one integer!
Apr 25, 2012 at 8:30pm UTC
->5->8->3
5*100+8*10+3*1=583
I think that was what coder777 was saying
int n=0;
for(node *x = list.first(); n!=NULL; n = n->Next()){
val+=x*10^n;
n++;
}
Last edited on Apr 25, 2012 at 8:35pm UTC
Apr 25, 2012 at 8:34pm UTC
Thx man, i feel stupid :S simple math xD
Apr 25, 2012 at 8:39pm UTC
Ha, its all good. Everyone has been there at one point or another.