weeken2013
错错错~来改错【第二集】

#include<stdio.h>

#include<stdlib.h>

#include"point.h"

#include<stdbool.h>

struct TreereeNode{

int dim,index;

bool left,right;

}tree[MAXN];

int sortDimension;

bool compare(int x,int y){

return point[x].p[sortDimension]<point[y].p[sortDimension];

}

它说我compare有错~不是说用<stdbool.h>这个头文件后可以用bool型么

王安泽
莫名奇妙的优越感
展开Biu

c++莫名奇妙的优越感,有算法库真是太好了

#10t

[查看全文]
ljm宅
你这个代码实现的功能是什么
展开Biu

话说 你这个代码实现的功能是什么?比较大小吗?头晕{:43_8913:}

[查看全文]
scropioczn
楼主定义的
展开Biu

weeken2013 发表于 2013-4-9 21:47

[mw_shl_code=c,true]

#include

#include

楼主定义的Point只是单纯结构体,不是变量类型啊,肿么cast?你要么把parameter里面写成struct Point *a, struct Point *b

或者用typedef把Point改成变量类型。

还有<stdbool.h>里面的bool应写成_Bool,eg. _Bool a = false;

你可以自己点开library去看定义。

[查看全文]
jains521
你确定返回的是
展开Biu

那个return你确定返回的是bool吗.

return a>b ? 1:0

应该是这样的表达式.

[查看全文]
terry182
定義了的話還需要打
展开Biu

weeken2013 发表于 2013-4-9 21:47

[mw_shl_code=c,true]

#include

#include

定義了的話還需要打struct 嗎? (我是不太清楚啦

[查看全文]
weeken2013
的确有中文字符
展开Biu

weeken2013 发表于 2013-4-9 21:23

[mw_shl_code=c,true]int compare(const void *a,const void *b){

struct Point *aa=(Point *) ...

的确有中文字符~不好意思啊~

[查看全文]
weeken2013
乖乖的寫
展开Biu

terry182 发表于 2013-4-9 21:35

乖乖的寫if的話會怎麼樣

[mw_shl_code=c,true]

#include<stdio.h>

#include<stdlib.h>

#include"point.h"

#include<stdbool.h>

struct TreereeNode{

int dim,index;

bool left,right;

}tree[MAXN];

int sortDimension;

int compare(const void *a,const void *b){

struct Point *aa=(Point *)a;

struct Point *bb=(Point *)b;

return(((aa->p[sortDimension])>(bb->p[sortDimension]))?-1:1);

}[/mw_shl_code]

buildTree.c: In function ‘compare’:

buildTree.c:12: error: ‘Point’ undeclared (first use in this function)

buildTree.c:12: error: (Each undeclared identifier is reported only once

buildTree.c:12: error: for each function it appears in.)

buildTree.c:12: error: expected expression before ‘)’ token

buildTree.c:13: error: expected expression before ‘)’ token

Point我在前边point.h里有啊,怎么破~~

[查看全文]
weeken2013
了沒有啊
展开Biu

terry182 发表于 2013-4-9 21:33

MAXN define 了沒有啊..

定义了~

[查看全文]