主题:[讨论]树遍历算法
数据库结构如下:
id parentid,name,money,totalmoney,submoney,extmoney,ismax
0,0,根节点,0,15000,0,0,false
1,0,张山,1000,5000,0,0,false
2,0,张好,2000,7000,0,0,false
3,0,王五,3000,3000,0,0,ture
4,1,黎明,4000,4000,0,0,false
5,2,老刘,5000,5000,0,0,false
通过数据库加载到tree
现在想计算submoney和extmoney.
submoney 是当前节点的totalmoney 减去下面所有层次的money.
并且要去掉当前下级节点的totalmoney最大值。(最大值已由ismax标注)
extmoney 是当前节点的下面三个层次的money*10%的和。
节点的数据结构如下
type
tmydata = record
id:integer;
parentid:integer;
name:string;
money:double;
totalmoney:double;
submoney:double;
extmoney:double;
ismax:boolean;
end;
pmydata = ^tmydata;
请大家帮忙看看
id parentid,name,money,totalmoney,submoney,extmoney,ismax
0,0,根节点,0,15000,0,0,false
1,0,张山,1000,5000,0,0,false
2,0,张好,2000,7000,0,0,false
3,0,王五,3000,3000,0,0,ture
4,1,黎明,4000,4000,0,0,false
5,2,老刘,5000,5000,0,0,false
通过数据库加载到tree
现在想计算submoney和extmoney.
submoney 是当前节点的totalmoney 减去下面所有层次的money.
并且要去掉当前下级节点的totalmoney最大值。(最大值已由ismax标注)
extmoney 是当前节点的下面三个层次的money*10%的和。
节点的数据结构如下
type
tmydata = record
id:integer;
parentid:integer;
name:string;
money:double;
totalmoney:double;
submoney:double;
extmoney:double;
ismax:boolean;
end;
pmydata = ^tmydata;
请大家帮忙看看