labsolve.c 861 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <stdbool.h>
  5. #include <limits.h>
  6. #include <assert.h>
  7. #define MAXCOLS 256
  8. #define MAXROWS 256
  9. /* Data type: Labyrinth - ASCII map, costs, direction */
  10. typedef struct labyrinth
  11. {
  12. char lab[MAXCOLS+2][MAXROWS];
  13. long costs[MAXCOLS][MAXROWS];
  14. long bestx[MAXCOLS][MAXROWS];
  15. long besty[MAXCOLS][MAXROWS];
  16. int maxrow;
  17. int startx;
  18. int starty;
  19. int treasurex;
  20. int treasurey;
  21. }LabCell, *Lab_p;
  22. int main(int argc, char* argv[])
  23. {
  24. FILE *in = stdin;
  25. Lab_p lab = NULL, handle;
  26. char* inp;
  27. if(argc > 2)
  28. {
  29. fprintf(stderr, "Usage: %s [<file>]\n", argv[0]);
  30. exit(EXIT_FAILURE);
  31. }
  32. if(argc == 2)
  33. {
  34. in = fopen(argv[1], "r");
  35. if(!in)
  36. {
  37. perror(argv[0]);
  38. exit(EXIT_FAILURE);
  39. }
  40. }
  41. lab LabRead(in);
  42. return 0;
  43. }