Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- //The defines
- #define ZERO 0
- #define ONE 1
- #define HUNDRED 100
- #define HUNDRED_ONE 101
- //The functions
- int changeArray(char palindrom[]);
- int main()
- {
- char palindrom[HUNDRED_ONE] = { 0 };
- printf("Enter string (max length 100 chars): ");
- fgets(palindrom , HUNDRED , stdin);
- changeArray(palindrom);
- }
- /*
- This function Makes the Array and check if this Palindrom
- input:The array
- output:none
- */
- int changeArray(char palindrom[])
- {
- int i = ZERO;
- int counter = ZERO; // only for bdika
- int len = strlen(palindrom) - ONE;
- int left = 0;
- int right = len - 1;
- while(left < right)
- {
- if(palindrom[left] != 32)
- {
- // if Aviel, while 0 < 4 for start
- if(palindrom[left] != palindrom[right])
- {
- printf("not a Palindrome");
- return;
- }
- else
- {
- left++; // Aviel => A -> v
- right--; // Aviel => l -> e
- }
- }
- else
- {
- left++;
- }
- if(palindrom[right] == 32)
- {
- right--;
- }
- }
- //if the array is palindrom
- printf("Palindrom");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement