Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- #include<cctype>
- using namespace std;
- int main(){
- int color[110]={};//梅花(club)=1 方塊(diamond)=2 紅心(heart)=3 黑桃(spade)=4
- int num[110]={};//A=1 J=11 Q=12 K=13
- char kind[110]={};
- int n;
- //===========cin===========
- cin>>n;
- char club[]={"club"};
- char diamond[]={"diamond"};
- char heart[]={"heart"};
- char spade[]={"spade"};
- for(int i=1;i<=n;i++){
- char colortmp[20];
- char numtmp[10];
- cin>>kind[i]>>numtmp>>colortmp;
- if(strcmp(colortmp,club)==0){
- color[i]=1;
- }
- if(strcmp(colortmp,diamond)==0){
- //cout<<"hi";
- color[i]=2;
- }
- if(strcmp(colortmp,heart)==0){
- color[i]=3;
- }
- if(strcmp(colortmp,spade)==0){
- color[i]=4;
- }
- if(numtmp[0]=='2'){
- num[i]=2;
- }
- if(numtmp[0]=='3'){
- num[i]=3;
- }
- if(numtmp[0]=='4'){
- num[i]=4;
- }
- if(numtmp[0]=='5'){
- num[i]=5;
- }
- if(numtmp[0]=='6'){
- num[i]=6;
- }
- if(numtmp[0]=='7'){
- num[i]=7;
- }
- if(numtmp[0]=='8'){
- num[i]=8;
- }
- if(numtmp[0]=='9'){
- num[i]=9;
- }
- if(numtmp[0]=='1'){
- num[i]=10;
- }
- if(numtmp[0]=='A'){
- num[i]=1;
- //cout<<"if a"<<endl;
- }
- if(numtmp[0]=='J'){
- num[i]=11;
- }
- if(numtmp[0]=='Q'){
- num[i]=12;
- }
- if(numtmp[0]=='K'){
- num[i]=13;
- }
- //cout<<(int)numtmp[0]<<endl;
- }
- /*/========test print==========
- cout<<"kind[i]"<<endl;
- for(int test=1;test<=n;test++){
- cout<<kind[test]<<" ";
- }
- cout<<endl;
- cout<<"num[i]"<<endl;
- for(int test=1;test<=n;test++){
- cout<<num[test]<<" ";
- }
- cout<<endl;
- cout<<"color[]"<<endl;
- for(int test=1;test<=n;test++){
- cout<<color[test]<<" ";
- }
- cout<<endl;
- *///==========test end==========
- int result[110]={};
- for(int i=1;i<=n;i++){
- if(kind[i]=='A'){
- result[i]=(((color[i]+2)*(num[i]+4))%8);
- }
- if(kind[i]=='B'){
- result[i]=(((color[i]+1)*(num[i]+7))%8);
- }
- if(kind[i]=='C'){
- result[i]=(((color[i]+3)*(num[i]+3))%8);
- }
- }
- /*/========test======
- for(int test=1;test<=n;test++){//test
- cout<<result[test]<<" ";
- }
- cout<<endl;
- *///======test=======
- int total[100]={};
- for (int i=1;i<=n;i++){
- int tmp=result[i];
- total[tmp]+=1;
- }
- /*/==========test========
- for(int test=0;test<=n;test++){//test
- cout<<total[test]<<" ";
- }
- cout<<endl;
- *///=====================
- int totalplus=0;//total 相加
- for(int i=0;i<=10;i++){
- if(total[i]>=2){
- totalplus+=total[i];
- //totalplus+=2;
- //cout<<"totalplus+=1 "<<i<<endl;
- }
- }
- //cout<<totalplus<<endl;
- //cout<<(double)totalplus/(double)(n*(n-1))<<endl;
- double ans=(double)totalplus/(double)(n*(n-1));
- ans=ans*100;
- ans=(int)(ans+0.5);
- cout<<(double)ans/100<<endl;
- }
- /*
- 8
- A A spade
- B 2 club
- C 5 diamond
- C J spade
- B 4 diamond
- C Q club
- A 10 heart
- B A club
- 8
- A A spade
- B 8 club
- C 5 diamond
- C k spade
- B 3 diamond
- C Q spade
- A 10 heart
- B A heart
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement