fork download
  1. #include <stdio.h>
  2. #define BASE = 0;
  3. char map0[]="A HAPP";
  4. int map0base;
  5. int map0size;
  6. char map1[]="Y NEW YE";
  7. int map1base;
  8. int map1size;
  9. char map2[]="AR!!!";
  10. int map2base;
  11. int map2size;
  12. char map3[]="I WISH YOU ";
  13. int map3size;
  14. int map3base;
  15. void print(int player);
  16. char table(int add);
  17.  
  18. void main(){
  19. map0base=0;
  20. map0size=(sizeof map0)-1;
  21. map1base=map0base+map0size;
  22. map1size=(sizeof map1)-1;
  23. map2base=map1base+map1size;
  24. map2size=(sizeof map2)-1;
  25. map3size=(sizeof map3)-1;
  26. map3base=map0base-map3size;
  27.  
  28. int w=2014;
  29. int player=3;
  30. while(1){
  31. print(player);
  32. printf("P position:%d\n",player);
  33. printf("\n\n");
  34. printf("Which way? 1:left 2:right 0:Exit\n");
  35. scanf("%d",&w);
  36. if(w==0)
  37. break;
  38. if(w==2)
  39. player++;
  40. else if(w==1)
  41. player--;
  42. else
  43. break;
  44. }
  45. return;
  46. }
  47.  
  48. void print(int player){
  49. int offset;
  50. int add;
  51. int map;
  52. for(offset=-3;offset<=3;offset++){
  53. add=player+offset;
  54. char map=table(add);
  55. printf("%c",map);
  56. }
  57. printf("\n");
  58. for(offset=-3;offset<=3;offset++){
  59. if(offset==0)
  60. printf("P");
  61. else
  62. printf(" ");
  63. }
  64. printf("\n");
  65. }
  66.  
  67. char table(int add){
  68. int m=0;
  69. if(map0base<=add && add<map0base+map0size)
  70. m=map0[add-map0base];
  71. else if(map1base<=add && add<map1base+map1size){
  72. m=map1[add-map1base];
  73. }
  74. else if(map2base<=add && add<map2base+map2size){
  75. m=map2[add-map2base];
  76. }
  77. else if(map3base<=add && add<map3base+map3size){
  78. m=map3[add-map3base];
  79. }
  80. else
  81. m=' ';
  82.  
  83. return m;
  84. }
  85.  
Success #stdin #stdout 0s 2252KB
stdin
2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 1 1 2 1 2 0
stdout
A HAPPY
   P   
P position:3


Which way? 1:left 2:right 0:Exit
 HAPPY 
   P   
P position:4


Which way? 1:left 2:right 0:Exit
HAPPY N
   P   
P position:5


Which way? 1:left 2:right 0:Exit
APPY NE
   P   
P position:6


Which way? 1:left 2:right 0:Exit
PPY NEW
   P   
P position:7


Which way? 1:left 2:right 0:Exit
PY NEW 
   P   
P position:8


Which way? 1:left 2:right 0:Exit
Y NEW Y
   P   
P position:9


Which way? 1:left 2:right 0:Exit
 NEW YE
   P   
P position:10


Which way? 1:left 2:right 0:Exit
NEW YEA
   P   
P position:11


Which way? 1:left 2:right 0:Exit
EW YEAR
   P   
P position:12


Which way? 1:left 2:right 0:Exit
W YEAR!
   P   
P position:13


Which way? 1:left 2:right 0:Exit
 YEAR!!
   P   
P position:14


Which way? 1:left 2:right 0:Exit
YEAR!!!
   P   
P position:15


Which way? 1:left 2:right 0:Exit
EAR!!! 
   P   
P position:16


Which way? 1:left 2:right 0:Exit
YEAR!!!
   P   
P position:15


Which way? 1:left 2:right 0:Exit
 YEAR!!
   P   
P position:14


Which way? 1:left 2:right 0:Exit
W YEAR!
   P   
P position:13


Which way? 1:left 2:right 0:Exit
EW YEAR
   P   
P position:12


Which way? 1:left 2:right 0:Exit
NEW YEA
   P   
P position:11


Which way? 1:left 2:right 0:Exit
 NEW YE
   P   
P position:10


Which way? 1:left 2:right 0:Exit
Y NEW Y
   P   
P position:9


Which way? 1:left 2:right 0:Exit
PY NEW 
   P   
P position:8


Which way? 1:left 2:right 0:Exit
PPY NEW
   P   
P position:7


Which way? 1:left 2:right 0:Exit
APPY NE
   P   
P position:6


Which way? 1:left 2:right 0:Exit
HAPPY N
   P   
P position:5


Which way? 1:left 2:right 0:Exit
 HAPPY 
   P   
P position:4


Which way? 1:left 2:right 0:Exit
A HAPPY
   P   
P position:3


Which way? 1:left 2:right 0:Exit
 A HAPP
   P   
P position:2


Which way? 1:left 2:right 0:Exit
U A HAP
   P   
P position:1


Which way? 1:left 2:right 0:Exit
OU A HA
   P   
P position:0


Which way? 1:left 2:right 0:Exit
YOU A H
   P   
P position:-1


Which way? 1:left 2:right 0:Exit
 YOU A 
   P   
P position:-2


Which way? 1:left 2:right 0:Exit
H YOU A
   P   
P position:-3


Which way? 1:left 2:right 0:Exit
SH YOU 
   P   
P position:-4


Which way? 1:left 2:right 0:Exit
ISH YOU
   P   
P position:-5


Which way? 1:left 2:right 0:Exit
WISH YO
   P   
P position:-6


Which way? 1:left 2:right 0:Exit
 WISH Y
   P   
P position:-7


Which way? 1:left 2:right 0:Exit
I WISH 
   P   
P position:-8


Which way? 1:left 2:right 0:Exit
 I WISH
   P   
P position:-9


Which way? 1:left 2:right 0:Exit
  I WIS
   P   
P position:-10


Which way? 1:left 2:right 0:Exit
   I WI
   P   
P position:-11


Which way? 1:left 2:right 0:Exit
  I WIS
   P   
P position:-10


Which way? 1:left 2:right 0:Exit
 I WISH
   P   
P position:-9


Which way? 1:left 2:right 0:Exit
I WISH 
   P   
P position:-8


Which way? 1:left 2:right 0:Exit
 I WISH
   P   
P position:-9


Which way? 1:left 2:right 0:Exit
  I WIS
   P   
P position:-10


Which way? 1:left 2:right 0:Exit
   I WI
   P   
P position:-11


Which way? 1:left 2:right 0:Exit
  I WIS
   P   
P position:-10


Which way? 1:left 2:right 0:Exit
   I WI
   P   
P position:-11


Which way? 1:left 2:right 0:Exit
  I WIS
   P   
P position:-10


Which way? 1:left 2:right 0:Exit