这个是我写的,高手帮忙看一下,谢谢。
#include <stdio.h>
#include <stdlib.h>
#define
  MAX_TERM
    100
#ifndef
  __MATRIX__H
struct Matrix ;
typedef struct Matrix * PtrToMatrix ;
typedef PtrToMatrix
  pmatrix ;
void InputVal(pmatrix
  a) ;
void Print(pmatrix a) ;
void Transposs(pmatrix a , pmatrix b) ;
struct Matrix {
       unsigned int row ;
       unsigned int col ;
       int
  value ;
};
#endif
 void InputVal(pmatrix
  a)
{
      unsigned int
  i ;
      scanf("%u%u%d" , &a[0].row ,&a[0].col,&a[0].value) ;
  //数组的第一个位置存储稀疏矩阵的行数,列数,非0元的个数
      for(i = 1 ; i <= a[0].value ; i++)
          scanf("%u%u%d" , &a[i].row ,&a[i].col,&a[i].value) ; //输入矩阵的行,列,对应值
 return ;
}
void Print(pmatrix
  a)
                 //这函数不知到思路对不对
{
           unsigned int
  i , j , k = 0 ;
           unsigned int current_row , current_col , current_val ;
           for(i = 0 ; i < a[0].row ; i++)
            {
                for(j = 0 ; j < a[0].col ; j++)
                {
                   current_row = a[k % a[0].value + 1].row ;
    //这不知怎么写,K总是与行,列对不齐
                   current_col = a[k % a[0].value + 1].col ;
                   current_val = a[k % a[0].value + 1].value ;
                   if(i == current_row && j == current_col)
                      printf("%d " , current_val ) ;
                   else
                       printf("0 ") ;
                   k++ ;
                }
               putchar('\n') ;
           }
}
/*这个转置函数的复杂度为O(columns*elements)*,怎么才能写成O(columns+elements)*/
void Transposs(pmatrix a , pmatrix b)
{
     unsigned int
  k = 1 , i , j ;
     b[0].col = a[0].row , b[0].row = a[0].col , b[0].value = a[0].value ;
     for(i = 0 ; i < a[0].col ; i++)
     {
         for(j = 1 ; j < a[0].value ; j++)
         {
             if(a[j].col == i)
              {
                 b[k].col = a[j].row ;
                 b[k].row = a[j].col ;
                 b[k].value = a[j].value ;
                 k++ ;
               }
          }
      }
}
int main(void)
{
      struct Matrix
   matrix_a[MAX_TERM] , matrix_b[MAX_TERM] ;
      InputVal(matrix_a) ;
      Transposs(matrix_a,matrix_b);
      Print(matrix_b) ;
  return 0 ;
}