I grew mine to 1200000 and finally got AC!

Regards,
Raysa
Moderator: Board moderators
Code: Select all
#include<iostream>
using namespace std;
const int MAX=1000000;
int main()
{
char str[MAX];
while(cin.getline(str,MAX))
{
for(int i=0;i<strlen(str);i++)
{
if((str[i]>='A'&&str[i]<='Z')||(str[i]>='a'&&str[i]<='z'))
{
if(str[i]!='a'&&str[i]!='e'&&str[i]!='i'&&str[i]!='o'&&str[i]!='u'&&str[i]!='A'&&str[i]!='E'&&str[i]!='I'&&str[i]!='O'&&str[i]!='U')
{
int k=i;
while((str[k+1]>='A'&&str[k+1]<='Z')||(str[k+1]>='a'&&str[k+1]<='z'))
{
cout<<str[k+1];
k++;
}
cout<<str[i]<<"ay";
i=k;
}
else
{
while((str[i+1]>='A'&&str[i+1]<='Z')||(str[i+1]>='a'&&str[i+1]<='z'))
{
cout<<str[i];
i++;
}
cout<<str[i]<<"ay";
}
}
else
cout<<str[i];
}
cout<<endl;
}
return 0;
}
Code: Select all
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define MAX 1000
#define KATA 1000
void main()
{
char kata[KATA];
char kalimat[MAX];
char dummy;
char vocal[11]={'a','i','u','e','o','A','I','U','E','O'};
long int idx;
long int kallen;
long int katalen;
long int voc;
long int ok;
long int awal,akhir,i,j,z;
#ifndef ONLINE_JUDGE
freopen ("492.in","r",stdin);
freopen ("492.out","w",stdout);
#endif
while (gets (kalimat))
{
kallen = strlen (kalimat);
idx=0;
awal=akhir=0;
while (idx<kallen)
{
ok=1;
memset(kata,0,KATA);
for (;idx<kallen;idx++)
{
if (isalpha (kalimat[idx])!=0)
{
awal=idx;
akhir=awal;
break;
}
else
{
printf ("%c",kalimat[idx]);
ok=0;
break;
}
}
for (;idx<=kallen&&ok==1;idx++)
{
if (isalpha (kalimat[idx])==0)
{
akhir=idx-1;
break;
}
}
if (ok==1)
{
for (z=0,i=awal;i<=akhir;i++,z++)
{
kata[z]=kalimat[i];
}
katalen=strlen(kata);
voc=0;
for (j=0;j<10;j++)
{
if (kata[0]==vocal[j])
{
voc=1;
break;
}
}
if (voc == 0)
{
for (i=1;i<katalen;i++)
{
printf ("%c",kata[i]);
}
printf ("%cay",kata[0]);
}
else
{
for(i=0;i<katalen;i++)
{
printf("%c",kata[i]);
}
printf ("ay");
}
}
else
{
idx++;
}
}
printf ("\n");
}
}
INPUT
This is the input.
He is a boy.
Object123oriented,..,.Programming
000000000
aaaaaaaaaaaa
Aaaaaaaaaaaa
computerprogrammingII
cse-1205 Computer programming II
check those with ur output->i hope it will help u to find out your code prob.OUTPUT
hisTay isay hetay inputay.
eHay isay aay oybay.
Objectay123orienteday,..,.rogrammingPay
000000000
aaaaaaaaaaaaay
Aaaaaaaaaaaaay
omputerprogrammingIIcay
secay-1205 omputerCay rogrammingpay IIay