492 - Pig-Latin

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

sampad74
New poster
Posts: 29
Joined: Wed Jun 18, 2014 3:57 pm
Location: Bangladesh

Re: 492 why RE?

Post by sampad74 »

Now,i am getting wrong ans.please,help.thanks in advance.Here is my code..

Code: Select all

got AC
Last edited by sampad74 on Tue Jul 22, 2014 4:58 am, edited 1 time in total.

lbv
Experienced poster
Posts: 128
Joined: Tue Nov 29, 2011 8:40 am

Re: 492 why RE?

Post by lbv »

sampad74 wrote:Now,i am getting wrong ans.please,help.thanks in advance.Here is my code..
The \b sequence is intended to be used in output devices that understand it and interpret it in a certain way. The idea is that a string like "fop\bo" appears as "foo". However, a judge bot doesn't work that way, it simply sees "fop\bo" as a different sequence of bytes than "foo".

Hence, try rewriting the program without using \b.

sampad74
New poster
Posts: 29
Joined: Wed Jun 18, 2014 3:57 pm
Location: Bangladesh

Re: 492 why RE?

Post by sampad74 »

Thank you,Ibv.I got AC.

Shafayat
New poster
Posts: 7
Joined: Mon Jan 19, 2015 11:32 am

Re: 492 - Pig-Latin

Post by Shafayat »

Got RTE. Can someone tell me why?

Code: Select all

#include<stdio.h>
#include<string.h>

int main()
{
	int a,b,c,d,e,f,g,h,i,j,k,l;
	char m[10000000],n[10000000],o;
	while(gets(m))
	{
		b=strlen(m);
		d=0;
		c=0;
		for(a=0;a<b;a++)
		{
			if((m[a]>='a' && m[a]<='z') || (m[a]>='A' && m[a]<='Z'))
			{
				if(c==0)
				{
				    if(m[a]=='a' || m[a]=='e' || m[a]=='i' || m[a]=='o' || m[a]=='u')
					{
						c=1;
						a--;
					}
					else if(m[a]=='A' || m[a]=='E' || m[a]=='I' || m[a]=='O' || m[a]=='U')
                    {
                        c=1;
						a--;
                    }
					else
					{
						o=m[a];
						c=2;
						a--;
					}
				}
				else if(c==1)
				{
					while((m[a]>='a' && m[a]<='z') || (m[a]>='A' && m[a]<='Z'))
					{
						n[d]=m[a];
						d++;
						a++;
						c=0;
					}
					n[d]='a';
					d++;
					n[d]='y';
					d++;
					a--;
				}
				else if(c==2)
				{
				    a++;
					while((m[a]>='a' && m[a]<='z') || (m[a]>='A' && m[a]<='Z'))
					{
						n[d]=m[a];
						d++;
						a++;
						c=0;
					}
					n[d]=o;
					d++;
					n[d]='a';
					d++;
					n[d]='y';
					d++;
					a--;
				}
			}
			else
			{
				n[d]=m[a];
				d++;
				c=0;
			}
		}
		n[d]='\0';
		puts(n);
	}
	return 0;
}

Post Reply

Return to “Volume 4 (400-499)”