Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int rek(int x) {
- int broj = 0;
- while(x > 0) {
- int cifra = x % 10;
- if(cifra <= 4) {
- cifra++;
- }
- else {
- cifra--;
- }
- broj = (broj * 10) + cifra;
- x /= 10;
- }
- int prevrten = 0;
- while(broj > 0) {
- int cifra = broj % 10;
- prevrten = (prevrten * 10) + cifra;
- broj /= 10;
- }
- return prevrten;
- }
- int main () {
- int n;
- scanf("%d", &n);
- printf("%d\n", rek(n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement