Palindrom mit C-Programmieren überprüfen?
Ich habe eine Aufgabe bekommen, wo ich mit einem C-Code überprüfen muss, ob das Wort oder ein Satz ein Palindrom ist. Ich habe folgendes ausprobiert, aber da sind paar Fehler drin, ich komm nicht weiter:
#include <stdio.h> #include <string.h> int main (){ char text[255]; int len =0; int i; int j; int z; char neu; printf("Bitte text eingeben"); fgets(text, 255, stdin); len = strlen(text); for (i=0; i != len; i++) if (text[i] >= 'A' && text[i] <= 'Z'){ text[i] += 32; } for (j = len; j >= 0; j--) printf("%c",text[j]); printf("\n"); if (text[j] == text[i]) { printf("palindrom"); } else { printf("kein palindrom"); } }
PC,
programmieren,
C,
Informatik,
C (Programmiersprache)