i just changed the following piece of code
[cpp]gets(a);
if(a[0]=='#')
break;
gets(b);[/cpp]
by this
[cpp]scanf("%[^\n]\n",a);
if(a[0]=='#')
break;
scanf("%[^\n]\n",b);[/cpp]
first one was AC(problem 10192) but the other one ran for more than a second an it got Output Limit Exceeded. Both of them ran well in my pc.
I have used scanf like above in other problem and it was ok.Any idea of why is this happening?
scanf and gets
Moderator: Board moderators
Re: scanf and gets
may be it is interpreted as any string not containing a '\' and a 'n'?44557FW wrote: [cpp]scanf("%[^\n]\n",a);
[/cpp]