2014 Fifth annual Blue Bridge Cup Java Undergraduate B group _ guess the alphabet

Source: Internet
Author: User

1 /*2 The 19-letter sequence of ABCD...S is repeated 106 times to get a string of length 2014. 3 Next, delete the 1th letter (the first letter a), and the 3rd, 5th, and all odd-numbered positions. 4 get the new string and then delete the odd position letter action.  In this case, there is only one letter left, please write the letter. 5 The answer is a lowercase letter, please submit the answer via the browser. Do not fill in any extra content. 6  */
7 Public classMain {8 Public Static voidMain (string[] args) {9String s = "ABCDEFGHIJKLMNOPQRS";TenString str = ""; One for(inti = 0; I < 106; i++) { Astr + = s;//Repeat Stitching - } - System.out.println (Str.length ()); the BooleanArr[] =New Boolean[Str.length ()]; - for(inti = 0; i < arr.length; i++) { -Arr[i] =true;//Mark whether the letter has been deleted (false to delete) - } + inti = 0;//Subscript for old strings (always str) - intCountnum = 0;//the subscript of a new string + intLeftnum = Str.length ();//the number of letters left after deletion A at while(Leftnum > 1) {//title description at the end of the day only one letter left - if(Arr[i] = =true) {//If the letter has not been deleted - if(countnum% 2 = = 0) {//If the subscript of the new string is an even number -Arr[i] =false;//Delete the letter -leftnum--;//number of remaining letters-1 - } incountnum++;//traverse a new string (a string of letters not deleted) - } toi++;//traversal of old strings (always str) + - if(i = = Str.length ()) {//if the loop is completed again, (the title describes the new string and then the action of deleting the odd position letter), the cyclic deletion theCountnum = 0;//set to 0 start again *i = 0; $ }Panax Notoginseng } - for(intj = 0; J < Arr.length; J + +) { the if(Arr[j] = =true) { + System.out.println (Str.charat (j)); A } the } + } -}

2014 Fifth annual Blue Bridge Cup Java Undergraduate B group _ guess the alphabet

Related Article

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.