fork download
  1. #include <stdio.h>
  2.  
  3. void PrintMatrix(int rowCount, int colCount, const int *m)
  4. {
  5. int i, j;
  6. for(i = 0; i < rowCount; ++i)
  7. {
  8. for(j = 0; j < colCount; ++j)
  9. {
  10. printf("%3d ", m[i * colCount + j]);
  11. }
  12. printf("\n");
  13. }
  14. }
  15.  
  16. int main(void)
  17. {
  18. int Sparse[4][3] = {{5, 0, 0}, {0, 0, -1}, {3, 0, 0}, {0, 9, 10}};
  19.  
  20. PrintMatrix(4, 3, Sparse[0]);
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 1676KB
stdin
Standard input is empty
stdout
  5   0   0 
  0   0  -1 
  3   0   0 
  0   9  10