Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int broj, svrten_broj = 0, ostatok;
- int originalen_broj;
- printf("Vnesi broj ");
- scanf("%d", &broj);
- originalen_broj = broj;
- /// 1, 2, 3, 4, 5
- /// 12345
- ///
- /// (1*10) + 2 = 12
- /// (12 * 10) + 3 = 123
- /// (123 * 10) + 4 = 1234
- /// (1234 * 10 ) +5 = 12345
- /// 54321
- ///
- int nov_broj = 0;
- while (broj != 0) {
- ostatok = broj % 10;
- svrten_broj = (svrten_broj * 10) + ostatok;
- broj /= 10;
- }
- printf("%d %d\n", originalen_broj, svrten_broj);
- if (originalen_broj == svrten_broj)
- printf("%d e palindrom", originalen_broj);
- else
- printf("%d ne e palindrom", originalen_broj);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment