New Ket Huawei Online Programming problem----simple password hack

Source: Internet
Author: User

The first topic is as follows:

/* * * * * *   Assuming that the original one BBS password for zvbo9441987, in order to facilitate memory, he through an algorithm to transform this password into YUANzhi1987, * This password is his name and year of birth, how to forget to forget, And can be blatantly placed in a conspicuous place without being known to the real password. *  * He's so changed, everybody knows the letters on the phone: 1--1, Abc--2, def--3, ghi--4, jkl--5, mno--6, pqrs--7,  * tuv--8 wxyz--9, 0--0, that's it. The lowercase letters that appear in the code become the corresponding numbers, and the numbers and other symbols do not change,  * */

First of all to analyze the topic, the first must be to distinguish between the case and the number, the distinction, the previous blog has been mentioned, the rest is the capitalization into lowercase, lowercase change the number, in fact, it is so simple. Here's the code:

1  Public classKillpassword {2 3          Public Static voidMain (string[] args) {4Scanner sc =NewScanner (system.in);5String Password =sc.nextline ();6             Char[] Chararray =Password.tochararray ();7             Char[] Newpasswordarray =New Char[chararray.length];8              for(inti = 0;i<chararray.length;i++){9                 intnum =Judgetype (Chararray[i]);Ten                 if(num = = 1){ One                     Charc =Big2small (Chararray[i]); ANewpasswordarray[i] =C; -}Else if(num = = 0){ -                     Charc =Small2num (Chararray[i]); theNewpasswordarray[i] =C; -}Else{ -Newpasswordarray[i] =Chararray[i]; -                 } +             } - System.out.println (newpasswordarray); +         } A          at          Public Static intJudgetype (Charc) { -              -             if(c >= ' A ' && C <= ' Z '){ -                 return1; -}Else if(c >= ' a ' && c<= ' z '){ -                 return0; in}Else{ -                 return10; to             } +         } -          the          Public Static CharSmall2num (Charc) { *             Switch(c) { $                  CaseA:Panax Notoginseng                  Case' B ': -                  CaseC: the                     return' 2 '; +                  Case' d ': A                  CaseE: the                  Case' F ': +                     return' 3 '; -                  Case' G ': $                  Case' H ': $                  CaseI: -                     return' 4 '; -                  Case' J ': the                  CaseK: -                  CaseL:Wuyi                     return' 5 '; the                  Case' m ': -                  CaseN: Wu                  Case' O ': -                     return' 6 '; About                  Case' P ': $                  Case' Q ': -                  Case' R ': -                  Case' s ': -                     return' 7 '; A                  Case' t ': +                  Case' U ': the                  Case' V ': -                     return' 8 '; $                  Case' W ': the                  Case' X ': the                  Case' Y ': the                  Case' Z ': the                     return' 9 '; -                 default: in                     return' 0 '; the             } the         } About          Public Static CharBig2small (Charc) { the             Char[] small = { the' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' H ', the' I ', ' j ', ' K ', ' l ', ' m ', ' n ', ' o ', ' P ', +' Q ', ' R ', ' s ', ' t ', ' u ', ' V ', ' w ', ' x ', -' Y ', ' z ' the             };Bayi             Char[] Big = { the' A ', ' B ', ' C ', ' D ', ' E ', ' F ', ' G ', ' H ', the' I ', ' J ', ' K ', ' L ', ' M ', ' N ', ' O ', ' P ', -' Q ', ' R ', ' S ', ' T ', ' U ', ' V ', ' W ', ' X ', -' Y ', ' Z ' the             }; the              for(inti = 0;i<big.length;i++) the                 if(c = =Big[i]) { the                     if(c = = ' Z ') -                         returnA; the                     Else the                         returnSmall[i + 1]; the                 }94             return' 0 '; the         } the}

New Ket Huawei Online Programming problem----simple password hack

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.