Array-14. Digital encryption (15)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.