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 |
<b>新手入门,第一次发帖,纪念我写了15327B#include <stdio.h> #include <string.h> struct PLAY { char color[15]; char num[15]; }; struct PLAY plays[4]; char a[100]; int main() { char flag; while(scanf("%c",&flag),flag!='#') { int i,len; int t=0; scanf("%s",a); len=strlen(a); scanf("%s",a+len); for(i=0; i<4; i++) { int j; t=i*2; for(j=0; j<13; j++) { plays[i].color[j]=a[t]; plays[i].num[j]=a[t+1]; t=t+8; } } getchar(); for(i=0; i<4; i++) { int j; for(j=0; j<12; j++) { char temp1,temp2; int t; for(t=0; t<12-j; t++) { if(plays[i].color[t]=='H'&&plays[i].color[t+1]!='H') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } else if(plays[i].color[t]=='S'&&plays[i].color[t+1]!='S'&&plays[i].color[t+1]!='H') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } else if(plays[i].color[t]=='D'&&plays[i].color[t+1]=='C') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } else if(plays[i].color[t]==plays[i].color[t+1]) { if(plays[i].num[t]=='A') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } else if(plays[i].num[t]=='K'&&plays[i].num[t+1]!='K'&&plays[i].num[t+1]!='A') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } else if(plays[i].num[t]=='Q'&&plays[i].num[t+1]!='Q'&&plays[i].num[t+1]!='K'&&plays[i].num[t+1]!='A') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } else if(plays[i].num[t]=='J'&&plays[i].num[t+1]!='Q'&&plays[i].num[t+1]!='K'&&plays[i].num[t+1]!='A'&&plays[i].num[t+1]!='J') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } else if(plays[i].num[t]>plays[i].num[t+1]&&plays[i].num[t+1]!='Q'&&plays[i].num[t+1]!='K'&&plays[i].num[t+1]!='A'&&plays[i].num[t+1]!='J') { temp1=plays[i].color[t]; plays[i].color[t]=plays[i].color[t+1]; plays[i].color[t+1]=temp1; temp2=plays[i].num[t]; plays[i].num[t]=plays[i].num[t+1]; plays[i].num[t+1]=temp2; } } } } } if(flag=='S') { printf("South player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[3].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("West player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[0].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("North player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[1].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("East player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[2].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); } if(flag=='N') { printf("South player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[1].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("West player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[2].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("North player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[3].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("East player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[0].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); } if(flag=='W') { printf("South player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[2].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("West player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[3].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("North player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[0].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("East player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[1].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); } if(flag=='E') { printf("South player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[0].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[0].num[i],plays[0].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("West player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[1].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[1].num[i],plays[1].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("North player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[2].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[2].num[i],plays[2].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); printf("East player:\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("| %c ",plays[3].color[i]); } printf("|\n"); for(i=0; i<13; i++) { printf("|%c %c",plays[3].num[i],plays[3].num[i]); } printf("|\n"); printf("+---+---+---+---+---+---+---+---+---+---+---+---+---+\n"); } printf("\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator