mihainan

Lab3 PC - ex 5 (CA)

Oct 21st, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int nr, ok, c, nr_invers, aux;
  7.     scanf("%d", &nr);
  8.     nr_invers = 0;
  9.     aux = nr;
  10.     while(nr != 0)
  11.     {
  12.         c = nr % 10;
  13.         nr_invers = nr_invers*10 + c;
  14.         nr = nr / 10;
  15.     }
  16.     nr = aux;
  17.     if(nr == nr_invers)
  18.     {
  19.         printf("Este palindrom!\n");
  20.     }
  21.     else
  22.     {
  23.         printf("Nu este palindrom!\n");
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment