Dynamic Matrix.c 895 B

1234567891011121314151617181920212223242526272829303132
  1. #define USE_TI89 // Compile for TI-89
  2. #define USE_TI92PLUS // Compile for TI-92 Plus
  3. #define USE_V200 // Compile for V200
  4. #define OPTIMIZE_ROM_CALLS // Use ROM Call Optimization
  5. #define MIN_AMS 100 // Compile for AMS 1.00 or higher
  6. #define SAVE_SCREEN // Save/Restore LCD Contents
  7. #include <tigcclib.h> // Include All Header Files
  8. #define M 10
  9. #define N 5
  10. int (*A)[N] = NULL;
  11. void _main (void)
  12. {
  13. int i,j;
  14. A = calloc (M, sizeof (*A)); // <I>allocation</I>
  15. for (i = 0; i < M; i++)
  16. for (j = 0; j < N; j++)
  17. A[i][j] = i*j; // fill 'A' with the multiplication table
  18. clrscr ();
  19. for (i = 0; i < M; i++)
  20. {
  21. for (j = 0; j < N; j++)
  22. printf ("%2d ", A[i][j]); // print out the matrix
  23. printf ("\n");
  24. }
  25. free (A); // free the memory
  26. ngetchx();
  27. }