نمایش نتایج 1 تا 2 از 2

نام تاپیک: راهنمایی درمورد اجرای یک کد

  1. #1

    راهنمایی درمورد اجرای یک کد

    سلام من میخوام این کد اجرا بشه ولی ارور میده


    run:
    Error: Could not find or load main class suffixtree.SuffixTree
    C:\Users\4ough\AppData\Local\NetBeans\Cache\8.2\ex ecutor-snippets\run.xml:53: Java returned: 1
    BUILD FAILED (total time: 0 seconds)




    .لطفا رراهنماییم بکنین که چه طور اجراش کنم؟






    import java.util.Random;

    public class SuffixTree {
    static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz0123456789\1\2";

    public static class Node {
    int begin;
    int end;
    int depth; // distance in characters from root to this node
    Node parent;
    Node[] children;
    Node suffixLink;

    Node(int begin, int end, int depth, Node parent) {
    this.begin = begin;
    this.end = end;
    this.parent = parent;
    this.depth = depth;
    children = new Node[ALPHABET.length()];
    }
    }

    public static Node buildSuffixTree(CharSequence s) {
    int n = s.length();
    byte[] a = new byte[n];
    for (int i = 0; i < n; i++) a[i] = (byte) ALPHABET.indexOf(s.charAt(i));
    Node root = new Node(0, 0, 0, null);
    Node node = root;
    for (int i = 0, tail = 0; i < n; i++, tail++) {
    Node last = null;
    while (tail >= 0) {
    Node ch = node.children[a[i - tail]];
    while (ch != null && tail >= ch.end - ch.begin) {
    tail -= ch.end - ch.begin;
    node = ch;
    ch = ch.children[a[i - tail]];
    }
    if (ch == null) {
    node.children[a[i]] = new Node(i, n, node.depth + node.end - node.begin, node);
    if (last != null) last.suffixLink = node;
    last = null;
    } else {
    byte t = a[ch.begin + tail];
    if (t == a[i]) {
    if (last != null) last.suffixLink = node;
    break;
    } else {
    Node splitNode = new Node(ch.begin, ch.begin + tail, node.depth + node.end - node.begin, node);
    splitNode.children[a[i]] = new Node(i, n, ch.depth + tail, splitNode);
    splitNode.children[t] = ch;
    ch.begin += tail;
    ch.depth += tail;
    ch.parent = splitNode;
    node.children[a[i - tail]] = splitNode;
    if (last != null) last.suffixLink = splitNode;
    last = splitNode;
    }
    }
    if (node == root) {
    --tail;
    } else {
    node = node.suffixLink;
    }
    }
    }
    return root;
    }

    // random test
    public static void main(String[] args) {
    Random rnd = new Random(1);
    for (int step = 0; step < 100_000; step++) {
    int n1 = rnd.nextInt(10);
    int n2 = rnd.nextInt(10);
    String s1 = getRandomString(n1, rnd);
    String s2 = getRandomString(n2, rnd);
    // build generalized suffix tree
    String s = s1 + '\1' + s2 + '\2';
    Node tree = buildSuffixTree(s);
    lcsLength = 0;
    lcsBeginIndex = 0;
    // find longest common substring
    lcs(tree, s1.length(), s1.length() + s2.length() + 1);
    int res2 = slowLcs(s1, s2);
    if (lcsLength != res2) {
    System.err.println(s.substring(lcsBeginIndex - 1, lcsBeginIndex + lcsLength - 1));
    System.err.println(s1);
    System.err.println(s2);
    System.err.println(lcsLength + " " + res2);
    throw new RuntimeException();
    }
    }
    }

    static int lcsLength;
    static int lcsBeginIndex;

    // traverse suffix tree to find longest common substring
    public static int lcs(Node node, int i1, int i2) {
    if (node.begin <= i1 && i1 < node.end) {
    return 1;
    }
    if (node.begin <= i2 && i2 < node.end) {
    return 2;
    }
    int mask = 0;
    for (char f = 0; f < ALPHABET.length(); f++) {
    if (node.children[f] != null) {
    mask |= lcs(node.children[f], i1, i2);
    }
    }
    if (mask == 3) {
    int curLength = node.depth + node.end - node.begin;
    if (lcsLength < curLength) {
    lcsLength = curLength;
    lcsBeginIndex = node.begin;
    }
    }
    return mask;
    }

    static int slowLcs(String a, String b) {
    int[][] lcs = new int[a.length()][b.length()];
    int res = 0;
    for (int i = 0; i < a.length(); i++) {
    for (int j = 0; j < b.length(); j++) {
    if (a.charAt(i) == b.charAt(j))
    lcs[i][j] = 1 + (i > 0 && j > 0 ? lcs[i - 1][j - 1] : 0);
    res = Math.max(res, lcs[i][j]);
    }
    }
    return res;
    }

    static String getRandomString(int n, Random rnd) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < n; i++) {
    sb.append((char) ('a' + rnd.nextInt(3)));
    }
    return sb.toString();
    }
    }












  2. #2

    نقل قول: راهنمایی درمورد اجرای یک کد

    لطفا راهنماییم کنید.من خیلی به این پروژه نیاز دارم

تاپیک های مشابه

  1. پاسخ: 3
    آخرین پست: یک شنبه 14 دی 1393, 09:47 صبح
  2. آموزش: مقدمه ایی بر آشنایی با Language-Integrated Query یا همان Linq
    نوشته شده توسط alimanam در بخش VB.NET
    پاسخ: 4
    آخرین پست: پنج شنبه 13 مهر 1391, 23:01 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •