标签:
http://poj.org/problem?id=2993
模拟大法好。
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 char q[10],w[100]; 6 char e[10],r[100]; 7 char white[12]= {‘K‘,‘Q‘,‘R‘,‘B‘,‘N‘,‘P‘}; 8 char black[12]= {‘k‘,‘q‘,‘r‘,‘b‘,‘n‘,‘p‘}; 9 char map1[18][35]; 10 int s1,s2; 11 int main() 12 { 13 int i,j; 14 for(i=1; i<=17; i++) 15 for(j=1; j<=33; j++) 16 { 17 if(i%2==1&&j%4==1) 18 map1[i][j]=‘+‘; 19 else if(i%2==1) 20 map1[i][j]=‘-‘; 21 else if(i%2==0&&j%4==1) 22 map1[i][j]=‘|‘; 23 else if(i%4==2&&(double)(j%8)/4<=1&&j%8!=0) 24 map1[i][j]=‘.‘; 25 else if(i%4==0&&((double)(j%8)/4>1||j%8==0)) 26 map1[i][j]=‘.‘; 27 else 28 map1[i][j]=‘:‘; 29 } 30 for(int k=1; k<=2; k++) 31 { 32 scanf("%s%s",q,w); 33 s1=strlen(w); 34 if(q[0]==‘W‘) 35 { 36 for(i=0; i<=5; i++) 37 for(j=0; j<=s1; j++) 38 { 39 if(w[j]==white[i]) 40 map1[2*(9-w[j+2]+‘0‘)][4*(w[j+1]-‘a‘)+3]=white[i]; 41 if(w[j]==‘,‘&&w[j+1]>96) 42 map1[2*(9-w[j+2]+‘0‘)][4*(w[j+1]-‘a‘)+3]=‘P‘; 43 } 44 } 45 if(q[0]==‘B‘) 46 { 47 for(i=0; i<=5; i++) 48 for(j=0; j<=s1; j++) 49 { 50 if(w[j]==white[i]) 51 map1[2*(9-w[j+2]+‘0‘)][4*(w[j+1]-‘a‘)+3]=black[i]; 52 if(w[j]==‘,‘&&w[j+1]>96) 53 map1[2*(9-w[j+2]+‘0‘)][4*(w[j+1]-‘a‘)+3]=‘p‘; 54 } 55 } 56 } 57 for(i=1; i<=17; i++) 58 { 59 for(j=1; j<=33; j++) 60 cout<<map1[i][j]; 61 cout<<endl; 62 } 63 return 0; 64 }
POJ 2993 Emag eht htiw Em Pleh 模拟
标签:
原文地址:http://www.cnblogs.com/CrazyBaby/p/5689758.html