Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- void drehen(char wort[100], int laenge)
- {
- char trow[100];
- char *head;
- char *back;
- int i,j=0;
- int counter = 0;
- int test;
- for (i = laenge; 0<=i; i--)
- {
- trow[j] = wort[i];
- j = j + 1;
- }
- for (i = 0; i <= laenge; i++)
- {
- putchar(trow[i]);
- }
- printf("\n\n");
- test = i / 2;
- head = &wort[0];
- back = &trow[0];
- back = back + 1;
- i = 0;
- while (i!=test)
- {
- if (*head == *back)
- counter = counter + 1;
- head = head + 1;
- back = back + 1;
- i=i + 1;
- }
- counter = (counter *2)+1;
- if (counter >= laenge)
- printf("Das Wort ist ein Palidrom!\n");
- else
- printf("Das Wort ist kein Palidrom!\n");
- }
- void convertieren(char *pchar)
- {
- while (*pchar != '\n')
- {
- if (*pchar >= 65 && *pchar<=90)
- *pchar = *pchar + 32;
- pchar = pchar + 1;
- }
- }
- int main(void)
- {
- char *pchar;
- int i = 0;
- FILE*datei;
- char wort[100];
- fopen_s(&datei,"Text.txt","r");
- fread(wort, sizeof(double), 100, datei);
- fgets(wort, 100, datei);
- fclose(datei);
- while (wort[i] != EOF)
- {
- putchar(wort[i]);
- i = i + 1;
- }
- pchar = wort;
- convertieren(pchar);
- drehen(wort, i);
- printf("\n");
- system("pause");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment