"Find the Goddess to qq number"--java article

Source: Internet
Author: User

The question is this:

Give a bunch of numbers (not QQ number), according to the following rules can find QQ number:

First the first number is deleted, and then the second number is placed at the end of the string, the third number is deleted, and the fourth number is placed at the end of this string of numbers ...

So loop, know the last number left, and delete the last number

According to the order just removed, the number of these numbers together is the goddess QQ number.

     Public Static voidMain (string[] arg0)throwsException {String QQ= "631758924"; String REALLYQQ= ""; String Temp= ""; intindex = 0; Queue<String> qqlist =NewLinkedlist<string>();  for(inti = 0; I < qq.length (); i++) {Qqlist.add (string.valueof (Qq.charat (i))); }         while(temp = Qqlist.poll ())! =NULL) {            if(index% 2 = = 0) {reallyqq+=temp; } Else{qqlist.add (temp); } Index++; } System.out.println (REALLYQQ);//615947283    }

"Find the Goddess to qq number"--java 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.