微信公众号 
图码生活

每天发布有五花八门的文章,各种有趣的知识等,期待您的订阅与参与
电脑报 1992-2001 十年文章全集
电脑报 1992-2001 十年文章全集
包含从 1992 年 - 2001 年间,两万余篇期刊文章,查询最少输入两个字符
随便看看
读取中
读取中
标题用十字链表解稀疏矩阵相加
栏目基础知识与讲座
发布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^.col<c)
  do q:=q^.right;
  if q^.right^.val+v=0
  then if q^.right^.col+v=0
  then begin
  q^.right:=q^.right^.right;  a;=1
  end
  else begin
  q^.right^.val:=q^.right^.val+v;  a:=1
  end
  else begin
  new(p); p^.row:=r; p^.col:=c;
  p^.vla:=v: p^.right:=q^.right;
  q^.right:=p
  end;
  q:=cp[c];
  while(q^.down<>cp[c]) and(q^.down^.row<r)
  do q:=q^.down;
  if a<>1 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.