blob: cff67ca4906e480d2a436a5a5130f0f3f67d468b (
plain) (
tree)
|
|
#include <string.h>
#include <stdio.h>
#define MIN(a,b) ((a)>(b)?(b):(a))
int palind (const char * c) {
int p = 0;
int l = strlen(c);
for (int i = 0; i < l; i++) {
if (c[i] == c[i+1]) {
printf("sodi\n");
p++;
for (int j = 1; j <= MIN(i, l-i-2); j++)
if (c[i-j] == c[i+1+j]) {
printf("nadaljevanje\n");
p++;
}
}
if (i && c[i-1] == c[i+1]) {
p++;
printf("lihi\n");
for (int j = 2; j < MIN(i, l-i-1); j++)
if (c[i-j] == c[i+j]) {
printf("nadaljevanje\n");
p++;
}
}
}
return p;
}
int main (int argc, char ** argv) {
if (argc != 1+1)
return 255;
return palind(argv[1]);
}
|