46 lines
		
	
	
	
		
			740 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			740 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include <stdio.h>
 | 
						|
#define MAX_SIZE 100
 | 
						|
 | 
						|
int top = -1;
 | 
						|
char stack[MAX_SIZE];
 | 
						|
 | 
						|
void push(char c) {
 | 
						|
    if (top < MAX_SIZE - 1) {
 | 
						|
        stack[++top] = c;
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
char pop() {
 | 
						|
    if (top >= 0) {
 | 
						|
        return stack[top--];
 | 
						|
    }
 | 
						|
    return '\0';
 | 
						|
}
 | 
						|
 | 
						|
int is_palindrome(char *str) {
 | 
						|
    int i;
 | 
						|
    for (i = 0; str[i] != '\0'; i++) {
 | 
						|
        push(str[i]);
 | 
						|
    }
 | 
						|
 | 
						|
    for (i = 0; str[i] != '\0'; i++) {
 | 
						|
        if (str[i] != pop()) {
 | 
						|
            return 0;
 | 
						|
        }
 | 
						|
    }
 | 
						|
    return 1;
 | 
						|
}
 | 
						|
 | 
						|
int main() {
 | 
						|
    char str[MAX_SIZE];
 | 
						|
    printf("Enter a string: ");
 | 
						|
    scanf("%s", str);
 | 
						|
 | 
						|
    if (is_palindrome(str)) {
 | 
						|
        printf("%s is a palindrome.\n", str);
 | 
						|
    } else {
 | 
						|
        printf("%s is not a palindrome.\n", str);
 | 
						|
    }
 | 
						|
 | 
						|
    return 0;
 | 
						|
}
 |