Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
怒贴一发 写死我了#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; char li[100]; struct luo { char x; int y,zi; }; struct luo map[20][10]; struct luo ans[5][500]; int chance(char p) { if(p=='K'||p=='k') return 1; if(p=='Q'||p=='q') return 2; if(p=='R'||p=='r') return 3; if(p=='B'||p=='b') return 4; if(p=='N'||p=='n') return 5; if(p=='P'||p=='p') return 6; if(p==':'||p=='.') return -1; } char su1(int k) { if(k==0) return 'a'; if(k==1) return 'b'; if(k==2) return 'c'; if(k==3) return 'd'; if(k==4) return 'e'; if(k==5) return 'f'; if(k==6) return 'g'; if(k==7) return 'h'; } int su2(int k) { if(k==4) return 4; if(k==5) return 3; if(k==6) return 2; if(k==7) return 1; if(k==0) return 8; if(k==1) return 7; if(k==2) return 6; if(k==3) return 5; } bool cmp(luo a,luo b) { if(a.zi==b.zi) { if(a.y==b.y) return a.x<b.x; return a.y<b.y; } return a.zi<b.zi; } bool cmp1(luo a,luo b) { if(a.zi==b.zi) { if(a.y==b.y) return a.x<b.x; return a.y>b.y; } return a.zi<b.zi; } int main() { int k=0,flag,l; for(int i=0; i<17; i++) { memset(li,0,sizeof(li)); scanf("%s",li); if(i%2==0) continue; int h=strlen(li); flag=0; l=0; for(int j=0; j<33;) { if(flag==0) { j+=2; flag=1; } else if(flag!=0) { j+=4; } map[k][l].x=su1(l); map[k][l].y=su2(k); map[k][l++].zi=chance(li[j]); } k++; } l--; int w1=0; for(int i=7; i>3; i--) { for(int j=0; j<l; j++) { if(map[i][j].zi!=-1) { ans[0][w1].x=map[i][j].x; ans[0][w1].y=map[i][j].y; ans[0][w1++].zi=map[i][j].zi; } } } sort(ans[0],ans[0]+w1,cmp); int w2=0; for(int i=0; i<4; i++) { for(int j=0; j<l; j++) { if(map[i][j].zi!=-1) { ans[1][w2].x=map[i][j].x; ans[1][w2].y=map[i][j].y; ans[1][w2++].zi=map[i][j].zi; } } } sort(ans[1],ans[1]+w2,cmp1); flag=0; printf("White: "); for(int i=0;i<w1;i++) { if(i!=0) printf(","); if(ans[0][i].zi==1) { printf("K%c%d",ans[0][i].x,ans[0][i].y); } if(ans[0][i].zi==2) { printf("Q%c%d",ans[0][i].x,ans[0][i].y); } if(ans[0][i].zi==3) { printf("R%c%d",ans[0][i].x,ans[0][i].y); } if(ans[0][i].zi==4) { printf("B%c%d",ans[0][i].x,ans[0][i].y); } if(ans[0][i].zi==5) { printf("N%c%d",ans[0][i].x,ans[0][i].y); } if(ans[0][i].zi==6) { printf("%c%d",ans[0][i].x,ans[0][i].y); } } cout<<endl; flag=0; printf("Black: "); for(int i=0;i<w2;i++) { if(i!=0) printf(","); if(ans[1][i].zi==1) { printf("K%c%d",ans[1][i].x,ans[1][i].y); } if(ans[1][i].zi==2) { printf("Q%c%d",ans[1][i].x,ans[1][i].y); } if(ans[1][i].zi==3) { printf("R%c%d",ans[1][i].x,ans[1][i].y); } if(ans[1][i].zi==4) { printf("B%c%d",ans[1][i].x,ans[1][i].y); } if(ans[1][i].zi==5) { printf("N%c%d",ans[1][i].x,ans[1][i].y); } if(ans[1][i].zi==6) { printf("%c%d",ans[1][i].x,ans[1][i].y); } } cout<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator