JOYOI1424 占卜DIY
Sol:
模拟即可。
TIPS:
1.理清思路再写。
2.注意各种特判和细节。(比如抽到13后虽直接退出但牌堆还是要下落)
AC CODE:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[15][6];
int cnt[15];
int main(){
for(int i=1;i<=13;i++){
for(int j=1;j<=4;j++){
char c;
scanf(" %c",&c);
if(c=='A') a[i][j]=1;
else if(c=='0') a[i][j]=10;
else if(c=='J') a[i][j]=11;
else if(c=='Q') a[i][j]=12;
else if(c=='K') a[i][j]=13;
else a[i][j]=c-'0';
}
}
for(int T=1;T<=4;T++){
int now=a[13][T];//生命牌
while(now!=13){
cnt[now]++;
a[now][0]=now;
int bottom=a[now][4];
for(int i=3;i>=0;i--) a[now][i+1]=a[now][i];
if(bottom==13) break;//抽牌后堆中牌下落
now=bottom;
}
}
int ans=0;
for(int i=1;i<=12;i++){
if(cnt[i]==4) ans++;
}
printf("%d",ans);
return 0;
}