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 |
wa,不知道为什么,请高手指点~#include<iostream> #include<algorithm> using namespace std; int n,m,i,j,score; char adam[26][2],eve[26][2],doing; int a[26],e[26];//转为数字后存储在这里 void tonum(){//将每张牌转化为数字 for(i=0;i<m;i++){ switch(adam[i][0]){ case'1':a[i]=1*100;break; case'2':a[i]=2*100;break; case'3':a[i]=3*100;break; case'4':a[i]=4*100;break; case'5':a[i]=5*100;break; case'6':a[i]=6*100;break; case'7':a[i]=7*100;break; case'8':a[i]=8*100;break; case'9':a[i]=9*100;break; case'T':a[i]=10*100;break; case'J':a[i]=11*100;break; case'Q':a[i]=12*100;break; case'K':a[i]=13*100;break; } switch(eve[i][0]){ case'1':e[i]=1*100;break; case'2':e[i]=2*100;break; case'3':e[i]=3*100;break; case'4':e[i]=4*100;break; case'5':e[i]=5*100;break; case'6':e[i]=6*100;break; case'7':e[i]=7*100;break; case'8':e[i]=8*100;break; case'9':e[i]=9*100;break; case'T':e[i]=10*100;break; case'J':e[i]=11*100;break; case'Q':e[i]=12*100;break; case'K':e[i]=13*100;break; } switch(adam[i][1]){ case'C':a[i]=a[i]+1;break; case'D':a[i]=a[i]+2;break; case'S':a[i]=a[i]+3;break; case'H':a[i]=a[i]+4;break; } switch(eve[i][1]){ case'C':e[i]=e[i]+1;break; case'D':e[i]=e[i]+2;break; case'S':e[i]=e[i]+3;break; case'H':e[i]=e[i]+4;break; } } } int main(){ cin>>n; doing=0; while(n--){ cin>>m; score=0; for(i=0;i<m;i++){ cin>>adam[i]; } for(i=0;i<m;i++){ cin>>eve[i]; } tonum(); sort(a,a+m);//排序 sort(e,e+m); for(i=m-1,j=m-1;i>=0,j>=0;){//从eve的最大一张开始数,比adam大的话score++,找到的话两人都看下一张,没找到则看adam的下一张 if(e[i]>a[j]){ score++; i--; j--; } else{ j--; } } cout<<score<<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