暑假集训做的第一个题,模拟,挺简单的,不过要细心点...
没什么好说的,直接贴代码;
1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 5 bool rec[33][33]; 6 int n,x,y; 7 char c; 8 9 int main() 10 { 11 while(scanf("%d",&n)!=EOF) 12 { 13 int m=1; 14 while(n--) 15 { 16 scanf("%d%d",&x,&y); 17 memset(rec,0,sizeof rec); 18 while(c=getchar()) 19 { 20 if(c=='.') break; 21 switch(c) 22 { 23 case 'E': 24 { 25 rec[32-y][x]=1; 26 x+=1; 27 } 28 break; 29 case 'N': 30 { 31 rec[31-y][x]=1; 32 y+=1; 33 } 34 break; 35 case 'W': 36 { 37 rec[31-y][x-1]=1; 38 x-=1; 39 } 40 break; 41 case 'S': 42 { 43 rec[32-y][x-1]=1; 44 y-=1; 45 } 46 break; 47 } 48 } 49 printf("Bitmap #%d ",m++); 50 for(int i=0; i<32; i++) 51 { 52 for(int j=0; j<32; j++) 53 if(rec[i][j]==1) 54 printf("X"); 55 else printf("."); 56 printf(" "); 57 } 58 if(n!=0) 59 printf(" "); 60 } 61 } 62 return 0; 63 }