The third session of Blue Bridge Cup Javac Group _ cipher Generator

Source: Internet
Author: User

/* (Start of program header comment)

* Copyright and version Declaration section of the program

* Copyright (c) 2016, Guangzhou Science and Technology Trade Vocational College, Department of Information Engineering students

* All rights reserved.

* File name: Blue Bridge Cup title

* Author: Pengjunhau

* Completion Date: April 01, 2016

* Version number: 001

* Description part of task and solution method

* Description of the problem:

When it comes to setting passwords for important permissions such as bank accounts, we often encounter such troubles: if you want to remember your birthday,
Easy to crack, unsafe, if you set a bad password, and you worry that you will forget it, if you write on paper, worry about the paper being
Others have found or lost ...

The task of this program is to convert a string of phonetic Alphabet to a 6-digit number (password). We can use any good-to-remember pinyin
string (such as name, Wang Ximing, write: wangximing) as input, the program outputs 6 digits.

The process of transformation is as follows:

The first step. Fold the string 6 a group, for example, wangximing into:
Wangxi
Ming

The second step. The ASCII values of all characters perpendicular to the same position are added to produce 6 numbers, as in the example above,
It is concluded that:
228 202 220 206 120 105

The third step. And then the number of each digit "indent" Processing: the number of each bit is added, the figure if not a
Number, it is then indented until it becomes a digit. For example: 228 = 2+2+8=12 = 1+2=3

The above number is reduced to: 344836, which is the final output of the program!

Requires the program to receive data from the standard input and output the results on the standard output.

The input format is: The first line is an integer n (<100), which indicates how many input rows are below, followed by n-line strings,
Is the string waiting to be transformed.
The output format is: N-line 6-bit password after transformation.

* Input Description:

For example, enter:
5
Zhangfeng
Wangximing
Jiujingfazi
Woaibeijingtiananmen
Haohaoxuexi

* Program output:

772243
344836
297332
716652
875843

* End of comment on the program head

*/

On the code:

Import Java.util.Scanner;

public class Main {

public static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
int n = sc.nextint ();
String arr[] = new String[n];
for (int i = 0; i < n; i++) {
Arr[i] = Sc.next ();
}
for (int i = 0; i < arr.length; i++) {
Z (Arr[i]);
}
}
public static void Z (String s) {
int num = 0;
int arr[] = new INT[6];
for (int i = 0; i < s.length (); i++) {
ARR[I%6] + = S.charat (i);
}
for (int i = 0; i < arr.length; i++) {
System.out.print (f (arr[i]));
}
System.out.println ();
}

public static int F (int n) {
int sum = 0;
if (n<10) {
return n;
}
while (n>0) {
sum + = n%10;
n/= 10;
}
return f (SUM);
}

}

The third session of Blue Bridge Cup Javac Group _ cipher Generator

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.