Hi, Actually when i=0 in the for loop it is printing a new line and the server is not finding the "Case 1:" pattern in the first line. Bcz the first line is starting from the second line. I have modified your program below kindly find the same.
On Sat, Apr 23, 2011 at 6:01 PM, chase <[email protected]> wrote: > sir, my code for the problem reverse string link :: > http://code.google.com/codejam/contest/dashboard?c=351101#s=p1 is > correct , it is giving correct output on my computer , but after > submitting this , it's giving error that output should start with case > #1: , eventhough my output is giving case 1#: my code is : > > > #include<stdio.h> > > #include<string.h> > > int main (int argc, const char * argv[]) { > int n,i,j,count,check=0,end=0; > int atlast,lastcheckpt,reverseprinting; > > scanf("%d",&n); > //fflush(stdin); > char a[n][25]; > for(i=0;i<n+1;i++) > { > gets(a[i]); > } > int numbercount=0; > for(i=0;i<n+1;i++) > { > if(numbercount!=0){ > printf("Case #%d: ",numbercount); > } > count=(strlen(a[i])); > > lastcheckpt=count; > for(j=count;j>-1;j--) > { > if(j==0){ > > for(atlast=0;atlast<lastcheckpt;atlast++) > { > printf("%c",a[i][atlast]); > > end=1; > > } > } > if(end==1){ > break; > } > > if(a[i][j]==' ') > { > > check=j; > > if(lastcheckpt==count) > { > > > for(reverseprinting=(check+1);reverseprinting<(lastcheckpt > +1);reverseprinting++) > { > > > printf("%c",a[i][reverseprinting]); > } > } > else > { > for(reverseprinting=(check > +1);reverseprinting<(lastcheckpt);reverseprinting++) > { > printf("%c",a[i][reverseprinting]); > > } > } > > printf(" "); > > > lastcheckpt=check; > } > > } > end=0; > > > * if(i>0)* > * printf("\n");* > numbercount++; > > } > } > > -- > You received this message because you are subscribed to the Google Groups > "google-codejam" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-code?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
