Program: 25.4.3.c
This commit is contained in:
parent
4bb1330acd
commit
464f599c06
41
25.4.3.c
Normal file
41
25.4.3.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
int is_palindrome(char *wort)
|
||||||
|
{
|
||||||
|
int len = strlen(wort);
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < len / 2; i++)
|
||||||
|
{
|
||||||
|
if (tolower(wort[i]) != tolower(wort[len - 1 - i]))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
char text[1001];
|
||||||
|
char *teiler = " ,:";
|
||||||
|
char *token;
|
||||||
|
|
||||||
|
printf("Geben Sie Zeilen ein:\n");
|
||||||
|
scanf("%1000[^\n]s",text);
|
||||||
|
|
||||||
|
token = strtok(text, teiler);
|
||||||
|
|
||||||
|
while (token != NULL)
|
||||||
|
{
|
||||||
|
if (is_palindrome(token) == 1)
|
||||||
|
{
|
||||||
|
printf("........ %s\n", token);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, teiler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user