用十字链表解稀疏矩阵相加 1995-01-27 writeln('please enter A row and col'); read(m,n): if m>n then s:=m else s:=m; new(p)' p^.row:=m; p^.col:=n; hm:=p cp[0]:=p; for i:=1 to s do begin new(p); p^.row=0; p^.col:=0; cp[i]:=p; p^.right:=p; p^.down:=p; p[i-1]^.next:=p end; cp[s]^.next:=hm; flag:=0; repeat if flag=0 then writeln('please enter A'); read(r,c,v); while(r<>rend) do{Rend为输入结束标志} begin q:=cp[r]; while(q^.right<>cp[r]) and (q^.right^.colcp[c]) and(q^.down^.row1 then begin p^.down:=q^.down; q^.down:=p end; read(r,c,v) end; if fiag=0 then r:=1.7E+38; writeln('please enter B') slse writeln('A+B='); flag:=1 until(r=rend); end.