Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Joseph Central Java implementation     - Easy to get hidden administrator account (Linux)

- Install Redis 2.6 5.5 32 position CentOS error resolved (Linux)

- Source Analysis: Java object memory allocation (Programming)

- Linux Command Tutorial: du command to view disk space (Linux)

- ntop monitoring software configuration and installation (Linux)

- Oracle inline view updates problems encountered (Database)

- command-line tool for send e-mail (Linux)

- Availability Hadoop platform - Oozie Workflow (Server)

- CentOS installed JDK8 (Linux)

- Eight kinds of techniques to solve hard problems Linux (Linux)

- Oracle Automatic Diagnostic Repository (Automatic Diagnostic Repository, ADR) (Database)

- SQL in the specific internal Oracle process (Database)

- Linux terminal interface font color settings (Linux)

- NAT and firewall under Linux (Linux)

- VMware installed Linux system and JDK deployment (Linux)

- How to run Kali Linux 2.0 in Docker container (Linux)

- The correct way of logical backup mysqldump (Database)

- How to install and use the Snort in Ubuntu 15.04 (Linux)

- C language to view various types of data size (Programming)

- Installation Enpass secure password manager on Ubuntu (Linux)

  Joseph Central Java implementation
  Add Date : 2018-11-21      
  What is Josephus it?

Josephus is the application of a mathematical problem: Given n individuals (identified by serial number 1,2,3 ... n, respectively) sitting around a round table. From the number of people began to count off k, m number to the person out of the line; his next person and from 1 Countin, count to m the man was out of the column; and so the law is repeated until the round table It was all out of the line.

We speak with the program, to achieve Josephus: eclipse jdk1.6

package code;

import java.awt.PointerInfo;
import java.util.Random;
import java.util.Scanner;

public class Josephus {
    private static class Node {
        public int no;
        public Node next;
        public Node (int no) {
            this.no = no;
            this.next = null;
    public static void main (String [] args) {
        / *
        Scanner input = new Scanner (System.in);
        System.out.println ( "taotal nums");
        int totalNum = input.nextInt ();
        System.out.println ( "size");
        int cycleNum = input.nextInt (); * /
        Random rand = new Random ();
        int totalNum = rand.nextInt (30);
        int cycleNum = rand.nextInt (5);
        if (cycleNum <= 1 || cycleNum> = totalNum) {
            System.out.println ( "error");
        Node header = new Node (1);
        Node pointer = header;
        for (int i = 2; i <= totalNum; i ++) {
            pointer.next = new Node (i);
            pointer = pointer.next;
        pointer.next = header;
        System.out.println (totalNum + "" + cycleNum);
        System.out.println ( "order output");
        while (pointer! = pointer.next) {
            for (int i = 1; i                 pointer = pointer.next;
            System.out.println (pointer.next.no);
            pointer.next = pointer.next.next;
        System.out.println (pointer.next.no);
- Manager Docker browser (Server)
- Linux Learning Notes: Users and Groups (Linux)
- IO reference Docker container (Server)
- C ++ type conversion and RTTI (Programming)
- Ubuntu 14.04 install PostgreSQL 9.2 (Database)
- Ubuntu uses under KVM + Qemu virtual machine build (Linux)
- Python substring format (Programming)
- Lua and C ++ (Programming)
- Ubuntu 14.04 installed Nvidia CUDA 7.5 and build Python Theano deep learning development environment (Linux)
- Linux server Php injection prevention (Linux)
- Big Data Common Glossary (Linux)
- C # how to generate a folder or file automatically rename (Programming)
- Java call by value and by reference (Programming)
- Linux directory structure (Linux)
- To install Oracle Database Details and FAQ Summary under CentOS (Database)
- The Zabbix2.4.5 source compiler installation under Ubuntu 14.04 (Server)
- Ubuntu 14.04 How to set up an SSH without password (Linux)
- Mass data storage application of MongoDB database (Database)
- Django url () function Detailed (Programming)
- CentOS 6 kernel upgrade to Kernel 3.x (Linux)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.