[問題] 二元樹 已解決
語言:C++
編譯器:在leetcode上 我也不知道編譯器是什麼
問題(Question):
小弟在刷leetcode中嘗試用二元樹解決一個題目
樹的結構長這個樣子
struct tree{
tree *r;
tree *l;
int val;
int count;
};
當這個樹要traversal時
只要樹中有超過二個元素,就會有這個error
Line 32: member access within misaligned address 0x000300000001 for type
'struct tree', which requires 8 byte alignment
看敘述貌似是資料的儲存空間對應不起來
void traversal(tree *node , vector<int> &solution){
if(node->count==1) solution.push_back(node->val); (←line32)
if(node->r) traversal(node->r,solution);
if(node->l) traversal(node->l,solution);
}
可是明明都是宣告int?
下面是完整程式碼
https://drive.google.com/open?id=0B2_MLdF4iY1lbWZ4NFNtZ0VDdkk
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.141.10.18
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1488723126.A.5ED.html
※ 編輯: worcdlo (223.141.10.18), 03/05/2017 22:14:35
推
03/05 22:31, , 1F
03/05 22:31, 1F
→
03/05 22:33, , 2F
03/05 22:33, 2F
→
03/05 22:35, , 3F
03/05 22:35, 3F
→
03/05 22:41, , 4F
03/05 22:41, 4F
→
03/05 22:41, , 5F
03/05 22:41, 5F
※ 編輯: worcdlo (223.141.10.18), 03/05/2017 22:49:08
→
03/05 22:58, , 6F
03/05 22:58, 6F
→
03/05 23:00, , 7F
03/05 23:00, 7F
→
03/05 23:02, , 8F
03/05 23:02, 8F
※ 編輯: worcdlo (223.141.10.18), 03/05/2017 23:04:07
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章
16
27