2013-10-10 4 views
1

나는 완전한 뉴비가 아니기 때문에 그것이 의미하는 바를 이해한다. 그러나 신비한 브래킷 Eclipse가 내가 놓친다 고 생각하는 것 같지 않다."예상 끝에 '}'입력 끝 '. 이 오류가 계속 발생하는 이유는 무엇입니까?

(나는 내가 내 코드에 구축 할 말을 내장하지 않은 사실 무시 -. 내가 멀리 아직 확보하지 못했를)

#include "./BinaryTree.h" 
using namespace ods; 
typedef BTNode1 Node; 
Node * buildNode(Node *p = NULL, Node *l = NULL, Node *r = NULL) { 
    Node * ans = new Node; 
    ans->parent = p; ans->left = l; ans->right = r; 
    return ans; 
} 

typedef BTNode1 Node; 
Node * buildNodeComplete(Node *p = NULL, Node*l = NULL, Node *r = NULL) { 
    Node * ans = new Node; 
    ans->parent = p; ans->left = l; ans->right = r; 
    return ans; 
} 

typedef BTNode1 Node; 
Node * buildNodeStringy(Node *p = NULL, Node*l = NULL, Node *r = NULL) { 
    Node * ans = new Node; 
    ans->parent = p; ans->left = l; ans->right = r; 
    return ans; 
} 

int main() { 
    // build random tree of 1023 nodes 
    BinaryTree<Node> T; 
    Node *u; 
    T.root() = buildNode(); 
    int d; 

    for (int i = 1; i < 1023; ++i) { 
     T.randomWalk(u, d); 
     if (d == 0) u->left = buildNode(u); 
     else u->right = buildNode(u); 
    } 

    //build complete tree of 1023 nodes 
    BinaryTree<BTNode1> C; 
    Node *a; 
    C.root() = buildNodeComplete(); 
    int g; 

    for (int i = 1; i <1023; i++) { 
     C.randomWalk(a, g); 
     if (g == 0) a->left = buildNodeComplete(a); 
     else a->right = buildNodeComplete(a); 
    } 

    //build stringy tree of 1023 nodes 
    BinaryTree<Node> S; 
    Node *q; 
    S.root() = buildNodeStringy(); 
    int v; 

    for (int i = 1; i <1023; i++) { 
     S.randomWalk(q, v); 
     if (v == 0) q->left = buildNodeStringy(q); 
     else q->right = buildNodeStringy(q); 
    } 

    // measure random walks in T 
    double sum=0; 
    double sum1=0; 
    double sum2=0; 
    for (int i = 0; i < 1000; ++i) { 
     T.randomWalk(u, d); 
     sum += T.depth(u); 
     C.randomWalk(a, g); 
     sum1 += C.depth(a); 
     S.randomWalk(q, v); 
     sum2 += S.depth(q); 
    } 

    std::cout << "Average length of random walk through arbitrary tree is " 
       << sum/1000; 
    std::cout << " and lg(n+1) = lg(1024) = 10." 
       << std::endl; 

    //lab 5 part b 
    std::cout << "Average length of random walk through complete tree is " 
       << sum1/1000 << endl; 
    std::cout << "Average length of random walk through stringy tree is " 
       << sum2/1000; 

    return 0; 
} 
+8

검사 (너무) 헤더 파일을 –

+1

당신이 경우 빌드를하면 오류가있는 곳을 알 수있다. –

+1

include 문에'. /'가 중복되어있다. ''include '문에서'' "'를 사용하면 기본적으로 소스 파일의 디렉토리를 먼저 찾습니다. –

답변

0

기발한 this bug in Eclipse fixed하지만 새로운 추가 시도 닫힌 괄호 다음의 행. 이전에는 .cpp 파일 끝에 새 줄 문자가 있어야했지만 실제로는 필요하지 않습니다. 내가 그에, 그래서 행운을 하나를 본 적이 있다면

또한,이 데이터 구조 클래스 할당과 같은 (이 쉽게 도달하기 전에 어려워집니다.)

관련 문제