Odpověď z MediaWiki API

This is the HTML representation of the JSON format. HTML is good for debugging, but is unsuitable for application use.

Specify the format parameter to change the output format. To see the non-HTML representation of the JSON format, set format=json.

See the complete documentation, or the API help for more information.

{
    "batchcomplete": "",
    "continue": {
        "gapcontinue": "Rie\u0161enia_testu_\u010d._3",
        "continue": "gapcontinue||"
    },
    "warnings": {
        "main": {
            "*": "Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
        },
        "revisions": {
            "*": "Because \"rvslots\" was not specified, a legacy format has been used for the output. This format is deprecated, and in the future the new format will always be used."
        }
    },
    "query": {
        "pages": {
            "931": {
                "pageid": 931,
                "ns": 0,
                "title": "Rie\u0161enia testu \u010d. 1",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "== \u00daloha \u010d. 1 ==\n\n<syntaxhighlight lang=\"java\">\nimport java.math.*;\n\npublic class BigFraction {\n    private BigInteger numerator;\n    private BigInteger denominator;\n\n    public BigFraction(BigInteger numerator, BigInteger denominator) {\n        this.numerator = numerator;\n        this.denominator = denominator;\n    }\n\n    public BigInteger getNumerator() {\n        return numerator;\n    }\n\n    public BigInteger getDenominator() {\n        return denominator;\n    }\n\n    public BigFraction reduce() {\n        BigInteger gcd = numerator.gcd(denominator);\n        BigInteger newNumerator = numerator.divide(gcd);\n        BigInteger newDenominator = denominator.divide(gcd);\n        if (denominator.signum() == -1) {\n            newNumerator = newNumerator.negate();\n            newDenominator = newDenominator.negate();\n        }\n        return new BigFraction(newNumerator, newDenominator);\n    }\n\n}\n</syntaxhighlight>\n\n== \u00daloha \u010d. 2 ==\n\n<syntaxhighlight lang=\"java\">\npackage trees;\n\npublic class And extends BinaryOperatorNode {\n\n    // ...\n\n    @Override\n    public Node negate() {\n        return new Or(getLeft().negate(), getRight().negate());\n    }\n}\n</syntaxhighlight>\n\n<syntaxhighlight lang=\"java\">\npackage trees;\n\npublic class Or extends BinaryOperatorNode {\n\n    // ...\n\n    @Override\n    public Node negate() {\n        return new And(getLeft().negate(), getRight().negate());\n    }\n\n}\n</syntaxhighlight>\n\n<syntaxhighlight lang=\"java\">\npackage trees;\n\npublic class Not extends UnaryOperatorNode {\n\n    // ...    \n\n    @Override\n    public Node negate() {\n        return getChild();\n    }\n\n}\n</syntaxhighlight>\n\n<syntaxhighlight lang=\"java\">\npackage trees;\n\npublic class Variable extends Node {\n    \n    // ...\n\n    @Override\n    public Node negate() {\n        return new Not(this);\n    }\n\n}\n</syntaxhighlight>\n\n== \u00daloha \u010d. 3 ==\n\n<syntaxhighlight lang=\"java\">\npublic class QuadraticForm {\n    private int[][] coefficients;\n    private int maximumVariableIndex;\n\n    public QuadraticForm() {\n        coefficients = new int[0][0];\n        maximumVariableIndex = Integer.MIN_VALUE;\n    }\n\n    public QuadraticForm(int coefficient, int i, int j) {\n        coefficients = new int[i + 1][j + 1];\n        coefficients[i][j] = coefficient;\n        if (coefficient != 0) {\n            maximumVariableIndex = Math.max(i, j);\n        } else {\n            maximumVariableIndex = Integer.MIN_VALUE;\n        }\n    }\n\n    public QuadraticForm(int[][] coefficients) {\n        maximumVariableIndex = Integer.MIN_VALUE;\n        this.coefficients = new int[coefficients.length][];\n        for (int i = 0; i <= coefficients.length - 1; i++) {\n            this.coefficients[i] = new int[coefficients[i].length];\n            for (int j = 0; j <= coefficients[i].length - 1; j++) {\n                this.coefficients[i][j] = coefficients[i][j];\n                if (coefficients[i][j] != 0) {\n                    maximumVariableIndex = Math.max(maximumVariableIndex, Math.max(i, j));\n                }\n            }\n        }\n    }\n\n    public int getCoefficient(int i, int j) {\n        if (coefficients.length <= i) {\n            return 0;\n        }\n        if (coefficients[i].length <= j) {\n            return 0;\n        }\n        return coefficients[i][j];\n    }\n\n    public int maximumVariableIndex() {\n        return maximumVariableIndex;\n    }\n\n    public int evaluate(int[] values) {\n        int sum = 0;\n        for (int i = 0; i <= coefficients.length - 1; i++) {\n            int xi = 0;\n            if (i <= values.length - 1) {\n                xi = values[i];\n            }\n            for (int j = 0; j <= coefficients[i].length - 1; j++) {\n                int xj = 0;\n                if (j <= values.length - 1) {\n                    xj = values[j];\n                }\n                sum += coefficients[i][j] * xi * xj;\n            }\n        }\n        return sum;\n    }\n\n    public QuadraticForm add(QuadraticForm other) {\n        int n = Math.max(Math.max(maximumVariableIndex(), other.maximumVariableIndex()), -1) + 1;\n        int[][] newCoefficients = new int[n][n];\n        for (int i = 0; i <= n - 1; i++) {\n            for (int j = 0; j <= n - 1; j++) {\n                newCoefficients[i][j] = getCoefficient(i, j) + other.getCoefficient(i, j);\n            }\n        }\n        return new QuadraticForm(newCoefficients);\n    }\n}\n</syntaxhighlight>"
                    }
                ]
            },
            "932": {
                "pageid": 932,
                "ns": 0,
                "title": "Rie\u0161enia testu \u010d. 2",
                "revisions": [
                    {
                        "contentformat": "text/x-wiki",
                        "contentmodel": "wikitext",
                        "*": "== \u00daloha \u010d. 1 ==\n\n<syntaxhighlight lang=\"java\">\nimport java.util.*;\n\npublic class ComparableArrayList<E extends Comparable<E>> extends ArrayList<E> implements Comparable<List<E>> {\n\n    public ComparableArrayList() {\n        super();\n    }\n\n    public ComparableArrayList(int initialCapacity) {\n        super(initialCapacity);\n    }\n\n    public ComparableArrayList(Collection<? extends E> c) {\n        super(c);\n    }\n\n    @Override\n    public int compareTo(List<E> o) {\n        Iterator<E> iterator = iterator();\n        Iterator<E> oIterator = o.iterator();\n        while (iterator.hasNext()) {\n            if (!oIterator.hasNext()) {\n                return 1;\n            }\n            E next = iterator.next();\n            E oNext = oIterator.next();\n            int c = next.compareTo(oNext);\n            if (c != 0) {\n                return c;\n            }\n        }\n        if (oIterator.hasNext()) {\n            return -1;\n        }\n        return 0;\n    }\n}\n</syntaxhighlight>\n\n== \u00daloha \u010d. 2 ==\n\n<syntaxhighlight lang=\"java\">\npublic static TreeMap<String, Integer> findFrequentStrings(Scanner scanner) {\n    TreeMap<String, Integer> result = new TreeMap<>();\n    while (scanner.hasNextLine()) {\n        String line = scanner.nextLine();\n        Map<String, Integer> frequencies = new HashMap<>();\n        int maxFrequency = 0;\n        Scanner lineScanner = new Scanner(line);\n        while (lineScanner.hasNext()) {\n            String s = lineScanner.next();\n            int current;\n            if (!frequencies.containsKey(s)) {\n                frequencies.put(s, current = 1);\n            } else {\n                frequencies.put(s, current = frequencies.get(s) + 1);\n            }\n            maxFrequency = Math.max(maxFrequency, current);\n        }\n        for (String s : frequencies.keySet()) {\n            if (frequencies.get(s) == maxFrequency) {\n                if (!result.containsKey(s)) {\n                    result.put(s, 1);\n                } else {\n                    result.put(s, result.get(s) + 1);\n                }\n            }\n        }\n    }\n    return result;\n}\n</syntaxhighlight>\n\n== \u00daloha \u010d. 3 ==\n\n<syntaxhighlight lang=\"java\">\nimport java.util.*;\n\npublic class RepeatedElementsIterator<E> implements Iterator<E> {\n    private Iterator<E> iterator;\n    private Map<E, Integer> repetitions;\n    private boolean hasNext;\n    private E next;\n    private int repetitionsLeft;\n\n    public RepeatedElementsIterator(Iterator<E> iterator, Map<E, Integer> repetitions) {\n        this.iterator = iterator;\n        this.repetitions = new HashMap<>(repetitions);\n        findNext();\n    }\n\n    private void findNext() {\n        hasNext = false;\n        while (iterator.hasNext() && !hasNext) {\n            E element = iterator.next();\n            if (!repetitions.containsKey(element)) {\n                repetitionsLeft = 1;\n            } else if (repetitions.get(element) > 0) {\n                repetitionsLeft = repetitions.get(element);\n            } else {\n                continue;\n            }\n            hasNext = true;\n            next = element;\n        }\n    }\n\n    @Override\n    public boolean hasNext() {\n        return hasNext;\n    }\n\n    @Override\n    public E next() {\n        if (hasNext()) {\n            E result = next;\n            if (--repetitionsLeft == 0) {\n                findNext();\n            }\n            return result;\n        } else {\n            throw new NoSuchElementException();\n        }\n    }\n}\n</syntaxhighlight>"
                    }
                ]
            }
        }
    }
}