int num = 0;
for(int i=0;i<A.size();i++){
num=num||(A[i]<3*i);
}
printf("%d",num);
I think this will do.
On Sun, Aug 21, 2011 at 2:25 PM, sarvesh saran
<[email protected]>wrote:
> Hi,
>
> I have a vector<int> A or an array (for C guys) that contains the octal
> representation of a number.
>
> So the array can be something like: [1,5,7] or [7,7,5,6,3,4,2] etc
>
> i.e no number in the array can be >= 8.
>
> Now given this array, I need to convert it its decimal representation.
>
> The naive way to do it would be to scan array from left to right, take each
> digit, multiply by 8 pow (x) where x is from 0 to ...n and compute sum.
>
> i.e something like:
>
> int oct = 1;
> int num = 0;
>
> for(<array length>){
> num+= oct * A[i];
> oct = oct * 8;
> }
>
> is there a faster way to do this? maybe using some STL container or
> algorithm. ?
>
> thanks,
> sarvesh
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.