Enter a four-digit number to encrypt it after output. The method is to add 9 to each digit of the number, then divide by 10 to take the remainder, as a new number on that bit, and finally the numbers on the thousand and 10 digits are exchanged, the hundred and the digits on the digit interchange, composing the new four digits after the encryption. For example, input 1257, after the addition of 9 to obtain the new number 0146, and then two times after the transposition to get 4601.
Input format:
The input gives a four-bit integer x in a row, which is the number that is required to be encrypted.
Output format:
The new number V is obtained in a row according to the format "the encrypted is V" output is encrypted.
Input Sample:
1257
Sample output:
The encrypted number is 4601
1#include <iostream>2#include <stdio.h>3#include <math.h>4#include <string.h>5#include <stdlib.h>6 7 using namespace:: STD;8 9 intMain () {Ten One intN; Ascanf"%d",&n); - inta[4]={0}; - inttemp=N; thea[3]=temp%Ten; - intI=2; - while((temp=temp/Ten)!=0) - { +a[i]=temp%Ten; -i--; + } A for(i=0;i<4; i++) at { -A[i]= (a[i]+9)%Ten; - } -temp=a[3]; -a[3]=a[1]; -a[1]=temp; intemp=a[2]; -a[2]=a[0]; toa[0]=temp; +printf"The encrypted number is"); - for(i=0;i<4; i++) the { *printf"%d", A[i]); $ } Panax Notoginseng return 0; -}
Array-14. Digital encryption (15)