-
Notifications
You must be signed in to change notification settings - Fork 101
/
palindrome_check.c
67 lines (62 loc) · 1.17 KB
/
palindrome_check.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
char stack[100];
int top = -1;
char palind[100];
int topp = -1;
void pushp(char x)
{
palind[++topp] = x;
}
char popp()
{
if (topp == -1)
return -1;
else
return palind[topp--];
}
int main()
{
{
/////////1
int k = 0;
char x;
printf("\n\nEnter the size of string : ");
scanf("%d", &k);
printf("Enter string\n");
for (int i = 0; i <= k; i++)
{
scanf("%c", &x);
pushp(x);
}
char m[k];
for (int i = 0; i <= k; i++)
{
m[i] = popp();
printf("%c", palind[i]);
}
printf("\n");
int count = 0;
for (int i = 0; i < k; i++)
{
if (palind[i+1] != m[i])
{
// printf("[%c](%c) ",palind[i], m[i]);
count++;
}
}
if (count == 0)
{
printf("palindrome\n");
}
else
{
printf("not palindrome\n");
}
}
}