当前位置: 代码迷 >> 综合 >> 悲剧的出牌 模拟题
  详细解决方案

悲剧的出牌 模拟题

热度:83   发布时间:2024-01-20 20:57:19.0

悲剧的队内赛,我还是太弱了= = 倒数第二的好成绩啊~~


悲剧的代码= = 300+啊~~~

#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <map>
using namespace std;struct node
{int date;int flower;
};
node p1[5];
node p2[5];bool cmp( node a,node b )
{if( a.date==b.date )return a.flower>b.flower;return a.date>b.date;
}
int cmpp( node a,node b )
{if( a.date==b.date ){    if( a.flower==b.flower )return 0;else if( a.flower>b.flower )return 1;else return -1;}else if( a.date>b.date )return 1;else return -1;
}
void judge( node sign1,node sign2 )
{int t=cmpp( sign1,sign2 );switch( t ){case -1:printf( "second\n");break;case 0:printf( "equal\n" );break;case 1:printf( "first\n" );break;}
}
int main()
{//freopen("e.in","r",stdin); freopen("e.out","w",stdout);int n;scanf( "%d",&n );while( n-- ){char d;char c;int i;memset( p1,0,sizeof(p1) );memset( p2,0,sizeof(p2) );for( i=0;i<5;i++ ){scanf( "\n%c%c",&d,&c );if( d<='9'&& d>='2' )p1[i].date=d-'0';else{switch( d ){case 'A':p1[i].date=14;break;case 'T':p1[i].date=10;break;case 'J':p1[i].date=11;break;case 'Q':p1[i].date=12;break;case 'K':p1[i].date=13;break;}}switch( c ){case 'S': p1[i].flower++;case 'H': p1[i].flower++;case 'C': p1[i].flower++;case 'D': p1[i].flower++;}//printf( "%d %d\n",p1[i].date,p1[i].flower );}for( i=0;i<5;i++ ){scanf( "\n%c %c",&d,&c );if( d<='9'&& d>='2' )p2[i].date=d-'0';else{switch( d ){case 'A':p2[i].date=14;break;case 'T':p2[i].date=10;break;case 'J':p2[i].date=11;break;case 'Q':p2[i].date=12;break;case 'K':p2[i].date=13;break;}}     switch( c ){case 'S': p2[i].flower++;case 'H': p2[i].flower++;case 'C': p2[i].flower++;case 'D': p2[i].flower++;}//printf( "%d %d\n",p2[i].date,p2[i].flower );//printf( "%d\n",p2[i].flower );}sort( p1,p1+5,cmp );sort( p2,p2+5,cmp );bool tonghua1=false;bool shunzi1=false;bool four1=false;bool three1=false;node sign1;bool tonghua2=false;bool shunzi2=false;bool four2=false;bool three2=false;node sign2;if( p1[0].date-p1[1].date==1 && p1[1].date-p1[2].date==1 && p1[2].date-p1[3].date==1 && p1[3].date-p1[4].date==1 ){shunzi1=true;sign1.date=p1[0].date;sign1.flower=p1[0].flower;}if( p1[0].flower==p1[4].flower && p1[1].flower==p1[2].flower && p1[2].flower==p1[3].flower && p1[3].flower==p1[4].flower ){tonghua1=true;sign1.date=p1[0].date;sign1.flower=p1[0].flower;}if( p1[1].date==p1[2].date && p1[1].date==p1[3].date ){if( p1[0].date==p1[1].date ){four1=true;sign1.date=p1[0].date;sign1.flower=p1[0].flower;}if( p1[4].date==p1[1].date ){four1=true;sign1.date=p1[1].date;sign1.flower=p1[1].flower;}}if( p1[2].date==p1[0].date ){three1=true;sign1.date=p1[0].date;sign1.flower=p1[0].flower;}if( p1[2].date==p1[4].date ){three1=true;sign1.date=p1[2].date;sign1.flower=p1[2].flower;}//-------------------------------------------------------if( p2[0].date-p2[1].date==1 && p2[1].date-p2[2].date==1 && p2[2].date-p2[3].date==1 && p2[3].date-p2[4].date==1 ){shunzi2=true;sign2.date=p2[0].date;sign2.flower=p2[0].flower;}if( p2[0].flower==p2[1].flower && p2[1].flower==p2[2].flower && p2[2].flower==p2[3].flower && p2[3].flower==p2[4].flower ){tonghua2=true; sign2.date=p2[0].date;sign2.flower=p2[0].flower;}if( p2[1].date==p2[2].date && p2[1].date==p2[3].date ){if( p2[0].date==p2[1].date ){four2=true;sign2.date=p2[0].date;sign2.flower=p2[0].flower;}if( p2[4].date==p2[1].date ){four2=true;sign2.date=p2[1].date;sign2.flower=p2[1].flower;}}if( p2[2].date==p2[0].date ){three2=true;sign2.date=p2[0].date;sign2.flower=p2[0].flower;}if( p2[2].date==p2[4].date ){three2=true;sign2.date=p2[2].date;sign2.flower=p2[2].flower;}//printf( "tonghua1%d shuzi1:%d four1:%d three1:%d\n",tonghua1,shunzi1,four1,three1);//printf( "tonghua1%d shuzi1:%d four1:%d three1:%d\n",tonghua2,shunzi2,four2,three2);//--------------------------------------------------------------------if( (tonghua1 && shunzi1) || (tonghua2 && shunzi2) ){if( (tonghua1 && shunzi1 ) && ( tonghua2 && shunzi2) ){ judge(sign1,sign2);}else if( tonghua1 && shunzi1 )printf( "first\n" );elseprintf( "second\n" );continue;}if( four1 || four2 ){if( four1 && four2 ){judge( sign1,sign2);}else if( four1 )printf( "first\n" );elseprintf( "second\n" );continue;}if( three1 || three2 ){//printf( "%d %d %d %d\n",sign1.date ,sign1.flower,sign2.date ,sign2.flower );if( three1 && three2 ){judge( sign1,sign2 );}else if( three1 )printf( "first\n" );elseprintf( "second\n" );continue;}if( tonghua1 || tonghua2 ){if( tonghua1 && tonghua2 ){judge( sign1,sign2 );}else if( tonghua1 )printf( "first\n" );elseprintf( "second\n" );continue;}judge( sign1,sign2 );}return 0;
}


  相关解决方案