|
|
back to boardHelp!!! WA on test 4 Please help me, I can't find error in my program, but WA4 #include<iostream.h> #include<stdlib.h> #include<string.h> #define SIZE 10000 int main() { char s1[SIZE], *s2; int i, k, t, j, done; cin >> s1; s2 = (char*) calloc (strlen (s1)+1, sizeof(char)); k = strlen (s1) - 1; for (i = k; i >= 0; i--) s2[i] = s1[k - i]; done = 0; for (i = 0; i <= k; i++) { for (j = i; j <= k; j++) { if ( s2[j-i] != s1[j] ) { done = 1; break; } } if (done == 0) { cout << s1; for (t = k - i + 1; t <= k; t++) cout << s2[t]; cout << endl; break; } done = 0; } delete s2;
return 0; } Re: Help!!! WA on test 4 For test 'aba' right answer is 'ababa' Read the problem more attentively. String should be not empty! Good luck! Re: Help!!! WA on test 4 Thanks, now all right, next time I'll be more attentive |
|
|