492 - Pig-Latin
Moderator: Board moderators
492 - Pig Latin.... How can I mark if it meet .,!etc?
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!
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!
Re: 492 - Pig Latin.... How can I mark if it meet .,!etc?
if (!isalpha(a)) ...
-
- New poster
- Posts: 13
- Joined: Wed Apr 29, 2009 11:37 am
- Location: Barcelona
Re: 492 - Pig Latin
Thanks to amr saqr for his inputs cases, they really helped me to get A 

Born to be wild
Re: 492: WA, dont know why...
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

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 ! 

492 need some critical input
#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;
}
#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;
}
Re: 492 need some critical input
* 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.
* 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.
Re: 492: WA, dont know why...
@Tausiq if the input length is more then array size then it will cause RTE.Judge's input may be too big that u can't grasp that in an array
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.
This may be the address of success.
-
- New poster
- Posts: 5
- Joined: Tue Sep 15, 2009 11:16 am
Why RTE >> Piglatin 492
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
Re: 492 - Pig Latin
theharshest your vode printts ay at the bigenning when the line starts with blankspaces.
-
- New poster
- Posts: 3
- Joined: Sun Mar 07, 2010 1:56 am
Re: Why RTE >> Piglatin 492
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...george3456 wrote:don't know why getting RTE..... help plzzzzzzzzzzz
Re: why WA?(492)piglatin
Hi everyone, for those who get RTE, I got ACC by using a char array of 10000000 and fgets() for taking input
Re: 492: WA, dont know why...
Obaida vai, BTMouseKing gave the post becoz he is getting WAObaida 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.
so, i mentioned some cases that might help him to recover from WA.
cause of RTE was just a free advice

I took an IQ test .. and the results were negative ! 

Re: 492: WA, dont know why...
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

-
- New poster
- Posts: 4
- Joined: Sat Jul 03, 2010 1:04 pm
492
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;
}
#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;
}
-
- New poster
- Posts: 2
- Joined: Thu Sep 09, 2010 7:20 pm
- Location: ?????? ????? ?? ???, ?????? ??? ?? ????
492 - Pig Latin
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;
}