Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int a, st, ml, ost;
- int pal = 1;
- int len = 0;
- scanf("%d", &a);
- int ac = a;
- while (ac != 0) {
- len++;
- ac /= 10;
- }
- for (int i = 0; i <= (len / 2); i++) {
- ost = pow(10, len - 2 * i - 1);
- st = a / ost;
- ml = a % 10;
- if (st != ml) {
- pal = 0;
- break;
- }
- a = (a - ost * st) / 10;
- if (a == 0) {
- break;
- }
- }
- if (pal == 1) {
- printf("palindrome");
- } else {
- printf("not palindrome");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement