Advertisement
ecco7777

Palindrom

Feb 19th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int x = 0;
  7.     int y = 0;
  8.  
  9.     char Feld[50];
  10.  
  11.     printf("gebe die buchstaben eines wortes nacheinander ein und am ende eine 0\n");
  12.     while (y != 1)
  13.     {
  14.         scanf("%c",&Feld[x]);
  15.         if (Feld[x]=='0')
  16.         {
  17.             y=1;
  18.         }
  19.  
  20.         x++;
  21.     }
  22.     x--;
  23.     while (x>=0)
  24.     {
  25.         printf("%c",Feld[x]);
  26.         if (Feld[x-1]!=Feld[(x-(x-1))])
  27.         {
  28.             y++;
  29.         }
  30.         x--;
  31.     }
  32.     if (y==0)
  33.     {
  34.         printf("das wort ist ein palindrom");
  35.     }
  36.     else
  37.     {
  38.         printf("das wort ist kein palindrom");
  39.     }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement