Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Joseph Central Java implementation     - The execution order of Oracle WHERE condition is not from right to left (Database)

- How do I switch from NetworkManager to systemd-network on Linux (Linux)

- N1QL bring SQL-like query NoSQL database experience (Database)

- Use HttpClient remote interface testing (Programming)

- Java in the final qualifier (Programming)

- How to configure HTTP Strict Transport Security (HSTS) (Linux)

- SQL statement to repair SQL Server database (Database)

- Go performed using iOS and Android programming (Programming)

- Simple steps allows you to build a more secure Linux server (Linux)

- Source code is installed MySQL 5.6.28 (Database)

- How to use Monit to deploy a server to monitor the system (Server)

- About Java 7 module system (Programming)

- Automatic batch resolve dependencies problem locally installed rpm package (Linux)

- Using Java arrays implement sequential stack (Programming)

- MySQL Statistics (Database)

- Merge Sort (Programming)

- How to install Wine 1.7.20 under Ubuntu or Linux Mint (Linux)

- Ubuntu / openSUSE users to install Veusz 1.21.1 (Linux)

- FileZilla FTP && TLS connection settings of (Linux)

- RedHat Linux 6.5 Enterprise Edition installation Redis 3.0.3 (Database)

 
         
  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");
            return;
        }
        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);
    }
}
     
         
       
         
  More:      
 
- CentOS-based Kickstart automated installation practice (Linux)
- Use preseed script to install Ubuntu 14.04 (Linux)
- Oracle online redefinition (Database)
- Access clipboard content across multiple vim instances in a terminal (Linux)
- How to remove the files inside the privacy of data on Linux (Linux)
- Docker ecosystem security is gradually maturing (Server)
- Spring AOP for logging (Programming)
- MariaDB 10.0.X, the dynamic column support JSON format to obtain data (Database)
- Automated Password Generator: Linux under a special password generator (Linux)
- Linux atomic operations and synchronization mechanisms (Programming)
- Java inner classes (Programming)
- Linux upgrade GCC 4.8.1 clear and concise tutorials (Ubuntu 12.04 64-bit version as an example) (Linux)
- Java factory pattern (Factory mode) (Programming)
- iOS custom keyboard emoji expression (Programming)
- Those functions under Linux you do not know the df command (Linux)
- Linux (Ubuntu) How iptables port mapping (Server)
- CentOS 6.5 platform offline compile and install PHP5.6.6 (Server)
- Linux 0.12 kernel and modern kernels difference in memory management (Linux)
- Try to use Lets Encrypt (Linux)
- VMware virtual machine to install CentOS 6.2 (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.