|
|
back to boardPlz Help Got WA for Test # 11 I got wrong answer for test #11 for the follwing code ...... can anybody tell the error in this code..... #include <stdio.h> void isPalendrome(char check[]); int flag1 = 0; main() { int i,j,k=1,l,len,upper_limit,lower_limit,n; char string[1001],check[1001]; scanf("%s", string); n = strlen(string); len = n-1; isPalendrome(string); while(flag1==0&&len>0) { k++; lower_limit=0; for(i=0;i<k;i++,lower_limit++) { for(j=lower_limit;j<len;j++) check[j] = string[j]; isPalendrome(check); if(flag1==1) break; } upper_limit = n-1; if(flag1==0) { for(i=0;i<k;i++,upper_limit--) { for(j=upper_limit,l=len-1;l>=0;j--,l--) check[l] = string[j]; isPalendrome(check); if(flag1==1) break; } } len--; check[len] ='\0'; }
}
void isPalendrome(char check[]) { int len,i,j,flag2=0; len = strlen(check); j = len-1; len = len/2; for(i=0;i<len;i++,j--) { if(check[i]!=check[j]) { flag2 = 1; break; } } if(flag2==0) { flag1 = 1; printf("%s",check); scanf("%s",check); return; } else return; } |
|
|