-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlg12q2.c
More file actions
63 lines (54 loc) · 789 Bytes
/
Copy pathlg12q2.c
File metadata and controls
63 lines (54 loc) · 789 Bytes
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "stack_char.h"
#include <ctype.h>
int palindrome(char sent[], stack_t st)
{
int len, i;
int value;
len = strlen(sent);
for ( i = 0; i < len; i++)
{
push(&st, sent[i]);
}
i = 0;
value = pop(&st);
while (toupper(sent[i])==toupper(value) && i < len )
{
i++;
if(!isEmptyS(&st))
value = pop(&st);
}
if (i==len)
{
return 1;
}
else
{
return 0;
}
}
void display(char arr[], int size)
{
for (int i = 0; i < size; i++)
{
printf("%s\n", arr[i]);
}
}
int main()
{
FILE*inp;
inp = fopen("palindrome.txt", "r");
char sent[50];
stack_t st;
initializeS(&st);
while (fscanf(inp," %[^\n]",sent)!=EOF)
{
if (palindrome(sent,st))
{
printf("%s\n", sent);
}
}
system("PAUSE");
}