AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
Permutations.java
Go to the documentation of this file.
1package aud.util;
2
6public class Permutations implements Iterable<int[]> {
7 int n_;
8
9 public Permutations(int n) { n_=n; }
10
11 @Override public PermutationIterator iterator() {
12 return new PermutationIterator(n_);
13 }
14
16 public static void main(String[] args) {
17
18 int n=args.length>0 ? Integer.parseInt(args[0]) : 3;
19
20 for (int[] p : new Permutations(n)) {
21 for (int j : p)
22 System.out.print(j);
23 System.out.println();
24 }
25 }
26}
Iterator over all permutations of length n.
Generate permutations.
static void main(String[] args)
demonstration and test
PermutationIterator iterator()