in this problem 10 is the largest base possible and so it always comes
in the end if it is at all present in the particular test case. so if
you are not a big fan of using in-built functions then the following
code might help:
char line[20];
int base[9];
cin.getline(line,20,'\n');
for(i=0,j=0;i<strlen(line);i++)
{
if(line[i]>='2'&&line[i]<='9')
base[j++]=line[i]-'0';
else if(line[i]=='1')
{
base[j++]=10;
break;
}
}
for(i=0;i<j;i++)
cout<<base[i]<<" ";
here base[] is the required array of bases.
hope it helps.
On May 17, 12:41 pm, maverick gugu <[email protected]> wrote:
> Hi All,
> Sorry that I'm pulling an old problem up. With reference to GCJ 09, round
> 1A problem a(Multi-base Happiness)
> URL:http://code.google.com/codejam/contest/dashboard?c=188266#s=p0
>
> How does one accept an arbitrary set of integers as input?
> -By reading an entire line and processing number by number is one method.
> But the problem is for two digit numbers..
>
> Just checked the code of others, but would be really nice if someone can
> explain it out more clearly in C/C++.(C would be great.)
> Thank you.
>
> -Maverick
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" 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
> athttp://groups.google.com/group/google-code?hl=en.
--
You received this message because you are subscribed to the Google Groups
"google-codejam" 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/google-code?hl=en.