()略
()求廣義表原子個數的遞歸模型如下
f(p)=
PROC Number(p:glist; VAR n: integer)
VAR m:integer;
n:=;
IF p<>NIL THEN
[IF p^tag= THEN n:= ELSE Number(p^sublistm)
n:=n+m; Number(p^linkm); n:=n+m; ]
ENDP;
int Count(glist *gl)
//求廣義表原子結點數據域之和原子結點數據域定義為整型
{if(gl==null) return();
else if (gl>tag==) return((p>data)+count(gl>link));
else return(count(gl>sublist)+count(gl>link)); }
}// Count
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/23025.html