Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- void encrypt(int num)
- {
- int length = -1;
- int num_copy = num; // a number to measure the length
- int num_left_to_right;
- int current_num;
- while(num_copy != 0)
- {
- length++;
- num_copy /= 10;
- }
- while(length > -1)
- {
- num_left_to_right = num * pow(10, (-1) * (length));
- current_num = num_left_to_right % 10;
- if(current_num == 0)
- current_num = 8;
- else if(current_num == 1)
- current_num = 9;
- else
- current_num -= 2;
- printf("%d", current_num);
- length--;
- }
- }
- void main()
- {
- encrypt(12034);
- }
Add Comment
Please, Sign In to add comment