Algorithm Sedgewick Fourth Edition-1th chapter BASIC-171 Joseph Question

Source: Internet
Author: User

1 /*************************************************************************2  * 3 * Josephus Problem4  *  5 *% java ex_1_3_37 7 26 * 1 3 5 0 4 2 67  *  8  *************************************************************************/9 Ten  Public classex_1_3_37 One { A      Public Static voidMain (string[] args) -     { -         intn = integer.parseint (args[0]), them = Integer.parseint (args[1]); -          -queue<integer> q =NewQueue<integer>(); -          for(inti = 0; I < n; i++) +Q.enqueue (NewInteger (i)); -          +         intK = 0; A          while(!q.isempty ()) at         { -             intx =q.dequeue (); -              -             if(++k% m = = 0) -Stdout.print (x + ""); -             Else in q.enqueue (x); -         } to stdout.println (); +     } -}

Algorithm Sedgewick Fourth Edition-1th chapter BASIC-171 Joseph Question

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.