fork download
  1. #include <stdio.h>//第2講演習問2
  2. #define W 8
  3. #define H 6
  4.  
  5. char map[H][W]={
  6. {1,1,1,1,1,1,1,1},
  7. {1,0,0,0,0,0,0,1},
  8. {1,0,1,1,1,0,1,1},
  9. {1,0,0,0,0,1,0,1},
  10. {1,0,0,1,0,0,2,1},
  11. {1,1,1,1,1,1,1,1},
  12. };
  13. void print_map(){
  14. int y,x;
  15. for(y=0;y<H;y++){
  16. for(x=0;x<W;x++){
  17. if(map[y][x]==0)printf(" ");
  18. else if(map[y][x]==1)printf("#");
  19. else if(map[y][x]==2)printf("G");
  20. }
  21. printf("\n");
  22. }
  23. }
  24. int main(void) {
  25. print_map();
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
########
#      #
# ### ##
#    # #
#  #  G#
########