In this particular problem there can be only one 2-digit number i.e.
10 and it can only appear in the end as it is the maximum base and the
numbers of the input would be in ascending order. so if you are not a
fan of using inbuilt functions you can try this in C:
char line[30];
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 integer array of bases obtained from the line.
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.