Commit 866745cc authored by Jean-Pierre Messager's avatar Jean-Pierre Messager
Browse files

FIX: palindrome_optimal

parent 207b095a
......@@ -16,9 +16,9 @@ int palindrome(char *s) {
longueur++;
}
// on copie à l'envers dans rev
// 01234 (longueur est 5)
// lapin
// nipal
// 012345 (longueur est 5)
// lapin0
// nipal0
for (i=0; i<longueur; i++) {
rev[i] = s[longueur - i - 1];
}
......
......@@ -31,7 +31,7 @@ int palindrome(char *s) {
start++;
end--;
}
return start == end || end == start + 1;
return *start == *end;
}
int main() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment