-
Notifications
You must be signed in to change notification settings - Fork 0
/
week9-9.c
45 lines (42 loc) · 875 Bytes
/
week9-9.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int palindromeChecker(char str[],int i,int j){
int h=j;
int l=i;
while(h<l){
if (str[l++] != str[h--])
{
return 0;;
}
}
return 1;
}
void printArray(char arr[],int i,int j){
int k;
for(k=i;k<=j;k++){
printf("%c",arr[k]);
}
printf("\n");
}
int main()
{
int i,j;
char str[100];
int count=0;
scanf("%s",str);
/*for(i=0;i<strlen(str);i++){
for(j=strlen(str)-1;j>=i;j--){
if(palindromeChecker(str,i,j)){
count++;
printArray(str,i,j);
i=j;
break;
}
}
}*/
if(palindromeChecker(str,0,strlen(str)-1)){
printArray(str,0,strlen(str)-1);
}
return 0;
}