fork download
  1. #include <stdio.h>
  2.  
  3. #define W 8
  4. #define H 6
  5.  
  6. // 全局变量
  7. char map[H][W] = {
  8. {1,1,1,1,1,1,1,1},
  9. {1,0,0,0,0,0,0,1},
  10. {1,0,1,1,1,0,1,1},
  11. {1,0,0,0,0,1,0,1},
  12. {1,0,0,1,0,0,2,1},
  13. {1,1,1,1,1,1,1,1},
  14. };
  15.  
  16. // 打印地图函数
  17. void print_map(void)
  18. {
  19. int x, y;
  20.  
  21. for(y = 0; y < H; y++)
  22. {
  23. for(x = 0; x < W; x++)
  24. {
  25. if(map[y][x] == 0)
  26. {
  27. printf(" ");
  28. }
  29. else if(map[y][x] == 1)
  30. {
  31. printf("#");
  32. }
  33. else if(map[y][x] == 2)
  34. {
  35. printf("G");
  36. }
  37. }
  38.  
  39. printf("\n");
  40. }
  41. }
  42.  
  43. int main(void)
  44. {
  45. print_map();
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
########
#      #
# ### ##
#    # #
#  #  G#
########