void createlindmat(linknode *hm[])//建立十字链表
{
    linknode *p,*q,*qq;//qq为了控制列或行的下标的大号先输入情况
    int rows,cols,terms;//稀疏矩阵行、列和非零个数
    int i,s;//s为确定要设立的头结点数
    printf("请分别输入稀疏矩阵的行、列数:");
    scanf("%d %d",&rows,&cols);
    printf("请输入稀阵非零元数的个数:");
    scanf("%d",&terms);
    p=(struct linknode *)malloc(sizeof(struct linknode));
    p->i=rows;
    p->j=cols;
    hm[0]=p;
    s=rows>cols?rows:cols;
    for(i=1;i<=s;i++)
        {
          p=(struct linknode *)malloc(sizeof(struct linknode));
          p->i=0;
          p->j=0;
          p->cptr=p->rptr=p;//建立循环的关建步骤
          hm[i]=p;
          hm[i-1]->k.next=hm[i];
        }
    hm[s]->k.next=hm[0];
    for(i=1;i<=terms;i++)//非零元素的输入
        {
          p=(struct linknode *)malloc(sizeof(struct linknode));
          printf("请输入第%d个非零元数的行、列号和值",i);
          scanf("%d %d %d",&p->i,&p->j,&p->k.v);
          if(p->i>0&&p->j>0&&p->i<=hm[0]->i&&p->j<=hm[0]->j)//保证行列下标从零开始不理睬
            {
              qq=q=hm[p->i];//从行建立链表
              while(q->rptr!=hm[p->i]&&q->j<p->j)
                {    
                  qq=q;  //qq是q的前驱
                  q=q->rptr;
                }
              if(q->j<p->j) //保证p都是后插入
                {
                  p->rptr=q->rptr;
                  q->rptr=p;
                }
              else
                {
                  p->rptr=qq->rptr;
                  qq->rptr=p;
                }
              qq=q=hm[p->j];//从列建立链表
              while(q->cptr!=hm[p->j]&&q->i<p->i)
                {
                  qq=p; //qq是q的前驱
                  q=q->cptr;
                }
              if(q->i<p->i) //保证p都是后插入
                {
                  p->cptr=q->cptr;
                  q->cptr=p->cptr;
                }
              else
                {
                  p->cptr=qq->cptr;
                  qq->cptr=p->cptr;
                }
            }
        }

}
[em13][em13][em13][em13][em13][em13][em13][em13][em13][em13][em13][em13][em13]