+ 1
#include <stdio.h> #include <string.h> int main() { char a[100]; int i,j,b=0,c; gets(a); c=strlen(a); for(i=0;i<c;i++)
Why it is not working for more than 2 words in medium level problem code coach pig latin
7 Antworten
+ 3
Your code is incomplete. Copy paste the code in code playground and post it here.
+ 1
Don't put code in question title
+ 1
Gordon
Arsenic
(This is not the answer)
Here's the code...
Fix it
Got it from the post
https://www.sololearn.com/post/263285/?ref=app
#include <stdio.h>
#include <string.h>
int main()
{ char a[100];
int i,j,b=0,c;
gets(a);
c=strlen(a);
for(i=0;i<c;i++)
{
if(a[i]!=' '){b++;}
else if(a[i]=' '){ for(j=i-(b-1);j<i;j++){printf("%c",a[j]);}
printf("%cay ",a[i-b]);
b=0;}
}
return 0;
}
+ 1
Allepu Madhan mohan
You printing when space encounters but since if there is no space after last word, it is missing printing last word..
0
#include <stdio.h>
#include <string.h>
int main()
{ char a[100];
int i,j,b=0;
gets(a);
int c=strlen(a);
a[c]=' ';
for(i=0;i<=c;i++)
{
if(a[i]!=' '){b++;}
else if(a[i]=' '){ for(j=i-(b-1);j<i;j++){printf("%c",a[j]);}
printf("%cay ",a[i-b]);
b=0;}
}
return 0;
}
0
Thanks to all I got it by adding a[c]=' '
0
def abc(str):
q=''
r=str.split( )
for i in r:
p=i[1:]+i[0]+'ay'+' '
q=q+p
print(q)
g=input()
abc(g)