josiftepe

Untitled

Dec 21st, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.     int broj, svrten_broj = 0, ostatok;
  4.     int originalen_broj;
  5.     printf("Vnesi broj ");
  6.     scanf("%d", &broj);
  7.     originalen_broj = broj;
  8. /// 1, 2, 3, 4, 5
  9.  /// 12345
  10.  ///
  11.  /// (1*10) + 2 = 12
  12.  /// (12 * 10) + 3 = 123
  13.  /// (123 * 10) + 4 = 1234
  14.  /// (1234 * 10 ) +5 = 12345
  15.  /// 54321
  16.  ///
  17.     int nov_broj = 0;
  18.     while (broj != 0) {
  19.         ostatok = broj % 10;
  20.         svrten_broj = (svrten_broj * 10) + ostatok;
  21.         broj /= 10;
  22.  
  23.     }
  24.     printf("%d %d\n", originalen_broj, svrten_broj);
  25.  
  26.     if (originalen_broj == svrten_broj)
  27.         printf("%d e palindrom", originalen_broj);
  28.     else
  29.         printf("%d ne e palindrom", originalen_broj);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment