[Procedure 48]

Source: Internet
Author: User

Question: A company uses a public phone to transmit data. The data is a four-digit integer and encrypted during the transmission process. The encryption rules are as follows: add 5 to each number, then, replace the number with the remainder divided by 10, and then exchange the first and fourth digits, and the second and third digits.

Import Java. util. *; public class lianxi48 {public static void main (string ARGs []) {S = new partition (system. in); int num = 0, temp; do {system. out. print ("enter a four-digit positive integer:"); num = S. nextint () ;}while (Num <1000 | num> 9999); int A [] = new int [4]; A [0] = num/1000; // The number A [1] = (Num/100) % 10; // The number A [2] = (Num/10) % 10; // take the ten digits A [3] = num % 10; // take the single digit for (Int J = 0; j <4; j ++) {A [J] + = 5; A [J] % = 10 ;}for (Int J = 0; j <= 1; j ++) {temp = A [J]; A [J] = A [3-J]; A [3-J] = temp;} system. out. print ("encrypted number:"); For (Int J = 0; j <4; j ++) system. out. print (A [J]) ;}}

[Procedure 48]

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.