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

Liphz
New poster
Posts: 1
Joined: Wed May 27, 2009 2:08 pm

492 - Pig Latin.... How can I mark if it meet .,!etc?

Post by Liphz »

Hi all...
Can u plz give me a code how can I mark if I meet any sign like .,!?/ and many more??? It can't be if(a=='.' || a==',' || a=='!' .......) right???
Help me ASAP plz...

Thx b4!

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: 492 - Pig Latin.... How can I mark if it meet .,!etc?

Post by mf »

if (!isalpha(a)) ...

Jordi Aranda
New poster
Posts: 13
Joined: Wed Apr 29, 2009 11:37 am
Location: Barcelona

Re: 492 - Pig Latin

Post by Jordi Aranda »

Thanks to amr saqr for his inputs cases, they really helped me to get A :wink:
Born to be wild

Tausiq
New poster
Posts: 6
Joined: Fri Mar 06, 2009 4:54 pm
Location: just here
Contact:

Re: 492: WA, dont know why...

Post by Tausiq »

Judge's input may be too big that u can't grasp that in an array, whatever the bound is :-?
so try to read the input character by character

do not use " fflush(stdin); "

This is a man.
hisTay isay aay anmay.

a
aay
I took an IQ test .. and the results were negative ! :(

layesh
New poster
Posts: 5
Joined: Wed Jun 10, 2009 10:13 pm

492 need some critical input

Post by layesh »

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

char s1[10000000];
char s2[10000000];

int main(){
int i,j,m,n,k,count,l;
freopen("492.txt","r",stdin);
count=0;
while(gets(s1)){
if(count>0)printf("\n");
count++;
l=strlen(s1);
n=0;
for(j=0;j<l;j++){
m=int(s1[j]);
if((m>=65&&m<=91)||(m>=97&&m<=123)){
s2[n]=s1[j];
n++;
}
else{
if(n==0)printf("%c",s1[j]);
else if(s2[0]=='a'||s2[0]=='e'||s2[0]=='i'||s2[0]=='o'||s2[0]=='u'||s2[0]=='A'||s2[0]=='E'||s2[0]=='I'||s2[0]=='O'||s2[0]=='U'){
for(k=0;k<n;k++){
printf("%c",s2[k]);
}
printf("ay");
printf("%c",s1[j]);
n=0;
}
else{
for(k=1;k<n;k++){
printf("%c",s2[k]);
}
printf("%c",s2[0]);
printf("ay");
printf("%c",s1[j]);
n=0;
}

}
}
if(j=l-1 && n>0){
if(s2[0]=='a'||s2[0]=='e'||s2[0]=='i'||s2[0]=='o'||s2[0]=='u'||s2[0]=='A'||s2[0]=='E'||s2[0]=='I'||s2[0]=='O'||s2[0]=='U'){
for(k=0;k<n;k++){
printf("%c",s2[k]);
}
printf("ay");
}
else{
for(k=1;k<n;k++){
printf("%c",s2[k]);
}
printf("%c",s2[0]);
printf("ay");
}
}
}
return 0;
}

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: 492 need some critical input

Post by mf »

* Don't start a new thread, do search for an existing thread for your problem and post there.
* Read existing replies in that thread before posting.
* Use [code]...[/code] tags to format source code.
* Post the source code exactly as you submit it to the judge. No freopen() calls and other junk.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 492: WA, dont know why...

Post by Obaida »

Judge's input may be too big that u can't grasp that in an array
@Tausiq if the input length is more then array size then it will cause RTE.
i think the case you mentioned below is a reason for WA.
try_try_try_try_&&&_try@try.com
This may be the address of success.

george3456
New poster
Posts: 5
Joined: Tue Sep 15, 2009 11:16 am

Why RTE >> Piglatin 492

Post by george3456 »

don't know why getting RTE..... help plzzzzzzzzzzz

Code: Select all

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

int main()
{
	char s[300000],t[300000];
	char temp;

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	while(gets(s))
	{
		long i,len;

		len = strlen(s);
		//printf("%d",len);

		for(i = 0;i<len;)
		{
			if(isalpha(s[i]))
			{
				if((s[i]!='a')&&(s[i]!='e')&&(s[i]!='i')&&(s[i]!='o')&&(s[i]!='u')&&
				   (s[i]!='A')&&(s[i]!='E')&&(s[i]!='I')&&(s[i]!='O')&&(s[i]!='U'))
				{
					temp = s[i++];
				}
				while(isalpha(s[i]))
					printf("%c",s[i++]);
				t[0] = temp;
				t[1] = '\0';
				strcat(t,"ay");
				printf("%s",t);
				temp = '\0';
			}
			if(!isalpha(s[i]))
			{
				//flag = 0;
				printf("%c",s[i++]);
			}
		}
	printf("\n");
	}

	
	return 0;
}	
The most important thing is never stop questioning ~ Albert Einstein

qwerty
New poster
Posts: 21
Joined: Sun Feb 08, 2009 5:26 pm
Location: Mumbai,India

Re: 492 - Pig Latin

Post by qwerty »

theharshest your vode printts ay at the bigenning when the line starts with blankspaces.

jhosimar3001
New poster
Posts: 3
Joined: Sun Mar 07, 2010 1:56 am

Re: Why RTE >> Piglatin 492

Post by jhosimar3001 »

george3456 wrote:don't know why getting RTE..... help plzzzzzzzzzzz
Hi for this problem you don't have to use gets() or scanf() the reason is, the input text is too big to store in any an array we plan/guess to declare, whether it is 1 million or 10 million elements!! so, get the input as character by character... you can use while(c=getchar()) and to finish if(c==EOF) return 0; otherwise check if is a letter or not and continue with the code...

obbY
New poster
Posts: 5
Joined: Sun May 16, 2010 11:41 pm

Re: why WA?(492)piglatin

Post by obbY »

Hi everyone, for those who get RTE, I got ACC by using a char array of 10000000 and fgets() for taking input

Tausiq
New poster
Posts: 6
Joined: Fri Mar 06, 2009 4:54 pm
Location: just here
Contact:

Re: 492: WA, dont know why...

Post by Tausiq »

Obaida wrote: @Tausiq if the input length is more then array size then it will cause RTE.
i think the case you mentioned below is a reason for WA.
Obaida vai, BTMouseKing gave the post becoz he is getting WA
so, i mentioned some cases that might help him to recover from WA.
cause of RTE was just a free advice :lol:
I took an IQ test .. and the results were negative ! :(

sh415
New poster
Posts: 13
Joined: Fri Nov 13, 2009 9:31 am
Location: JU

Re: 492: WA, dont know why...

Post by sh415 »

This is a man.
hisTay isay aay anmay.

a
aay

I got AC in this in this problem............
I think there is some problem in problem description :
Each line of text will contain one or more words. A ``word'' is defined as a consecutive sequence of letters (upper and/or lower case).

this cnflicts the case a-> aay; as it is given the definition of "word".....................
any way judges thinks a single character is a word :( ........... thanks

rafay-hasan
New poster
Posts: 4
Joined: Sat Jul 03, 2010 1:04 pm

492

Post by rafay-hasan »

i got RTE for this problem.can anyone please help me!!!!!!!!


#include<stdio.h>
#include<string.h>
int main()
{
char a[1000000];
long c1,i,k,m;
while(gets(a))
{
c1=strlen(a),k=0;
for(i=0;i<c1;i++)
{
if(a==32)
{
if(a[k]==65|| a[k]==69 || a[k]==73||a[k]==79||a[k]==85||a[k]==97||a[k]==101||a[k]==105||a[k]==111||a[k]==117)
{
for(m=k;m<i;m++)
printf("%c",a[m]);
printf("ay");
printf("%c",a);
k=i+1;
}
else
{
for(m=k+1;m<i;m++)
printf("%c",a[m]);
printf("%c",a[k]);
printf("ay");
printf("%c",a);
k=i+1;
}
}
if(i+1==c1)
{
if(a[k]==65|| a[k]==69 || a[k]==73||a[k]==79||a[k]==85||a[k]==97||a[k]==101||a[k]==105||a[k]==111||a[k]==117)
{
for(m=k;m<=i;m++)
printf("%c",a[m]);
printf("ay");
k=i+1;
}
else
{
for(m=k+1;m<=i;m++)
printf("%c",a[m]);
printf("%c",a[k]);
printf("ay");
k=i+1;
}
}
}
printf("\n");
}
return 0;
}

Shiba
New poster
Posts: 2
Joined: Thu Sep 09, 2010 7:20 pm
Location: ?????? ????? ?? ???, ?????? ??? ?? ????

492 - Pig Latin

Post by Shiba »

Anyone plz help!! I've got RTE :(. Is there any problem with gets() or the array size? How can I take input using fgets() ??

Code: Select all

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

int main () {
    
    char line[10000000], temp;
    long i, start, k, len;
    bool flag;
    
    while(gets(line)) {
        
        len = strlen(line);
        start = 0;
        flag = false;

        while(1){
            for(i=start; i<len; i++) {
                if(!isalpha(line[i]))
                    break;
            }

            for(k=start; k<i; k++) {
                if(line[start] == 'A' || line[start] == 'a' || line[start] == 'E' || line[start] == 'I' || line[start] == 'i' || line[start] == 'O' || line[start] == 'o' || line[start] == 'U' || line[start] == 'u') {
                    for(k=start; k<i; k++)
                        if(!isalpha(line[k])) {
                            temp = line[k];
                            flag = true;
                        }
                        else
                            printf("%c", line[k]);
                    printf("ay");
                }
                else if(line[start] != 'A' || line[start] != 'a' || line[start] != 'E' || line[start] != 'I' || line[start] != 'i' || line[start] != 'O' || line[start] != 'o' || line[start] != 'U' || line[start] != 'u') {
                    for(k=start+1; k<i; k++)
                        if(!isalpha(line[k])) {
                            temp = line[k];
                            flag = true;
                        }
                        else
                            printf("%c", line[k]);
                    printf("%cay", line[start]);
                }

                if(flag) {
                    printf("%c", temp);
                    flag = false;
                }
                break;
            }

            if(i == len) {
                printf("\n");
                break;
            }
            else {
                printf("%c", line[i]);
                start = i + 1;
            }
        }
    }
    return 0;
}

Post Reply

Return to “Volume 4 (400-499)”