+ 1
About pig latin problem
I'm stuck with this code... Inspite of my output bring right 5/5 tests have failed .. please help ? #include <stdio.h> #include<string.h> int main() {int i,j,n,k=0,l=0; char a[100]; fgets(a,100,stdin); n=strlen(a); for (i=0;i<n;i++) { if(a[i]==' ') k++; } for (i=0;i<k+1;i++) { for (j=l+1;a[j]!=' ';j++) { if(j<=n) {printf("%c",a[j]);}} printf("%cay",a[l]); l=j+1; if (i<k) printf(" "); } return 0; }
5 Antworten
0
You are not outputting the way it should be then ,check the test 1 and test 2 results ,it should tell you the errors
0
https://www.sololearn.com/coach/16?ref=app
No errors are shown
0
Monika
By your code this statement
for (j=l+1;a[j]!=' ';j++)
It is going to Infinite loop...
So to stop it, add like
a[n] = ' ' ; a space at last to input...
0
Jayakrishna🇮🇳
Thank you soo much
a[n]=' ' .Fixed the problem
0
Monika you're welcome..