Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int x = 0, y = 0;
  6. int map[5][5] = { {'X', 'W', 'X', 'X', 'X'},
  7. {'X', 'W', 'X', 'X', 'X'},
  8. {'X', 'X', 'X', 'W', 'X'},
  9. {'W', 'W', 'W', 'X', 'X'},
  10. {'X', 'X', 'X', 'X', 'X'}};
  11. while(1)
  12. {
  13. char ch;
  14. scanf("%c", &ch);
  15.  
  16.  
  17. if(ch == 'u')
  18. x -= 1;
  19. else if(ch == 'd')
  20. x += 1;
  21. else if(ch == 'l')
  22. y -= 1;
  23. else if(ch == 'r')
  24. y += 1;
  25. else if(ch == 'q')
  26. break;
  27. else
  28. continue;
  29.  
  30.  
  31. for(int i = 0; i < 5; i++)
  32. {
  33. for(int j = 0; j < 5; j++)
  34. {
  35. if(map[i][j] == 1)
  36. printf("O");
  37. else
  38. printf("X");
  39. }
  40. printf("\n");
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement