The fifth chapter of the title industry

Source: Internet
Author: User

5.5

Below will give two people play a game of poker, try to design a simulation program, its basic functions are:

(a) (1) The hands of the hand (using the random number generator).

(b) (2) determine the winner and the type of winning card.

The rules of the poker game are as follows:

(1) There are two people playing for a and Brespectively.

(2) a deck of cards with a card ,4 colors (Spades, Hearts , clubs, squares), each suit of cards in ascending order of the number of points 2 , 3,4,... .. , Ten , J,q,k,a wait - species.

(3) for each person to send three cards, cards face up, the winner can be determined immediately.

(4) the highest level of the hand to become the same flower, that is , 3 cards are the same suit, the largest flush is the same color of the q,k,a.

(5) The second level of the card is called the straight, that is, the number of consecutive 3 cards, the largest cis is a different color q,k,a

(6) The third level of the card is the same point, that is, the same number of points of three cards, the largest is the same point AAA.

(7) The fourth level of the card is a pair, that is, 3 cards have two points in the same number, the largest pair is a,a,k.

(8) The fifth level of the card is a non-brand, that is, remove the above 4 and so on any hand, the largest is a different color a.k,j.

(9) if the card type of two people is different, then the highest level wins, if the same level, then the higher the number of points wins; If the points are the same, a draw.

The procedure is as follows:

#include "stdio.h"

int rabl (int a,int b,int *r)

{

int l,k,m,i,p;

k=b-a+1;

l=2;

while (i<=1)

{

K=k+k+k+k+k;

k=k%m;

L=k/4+a;

if (l<=b)

{

p=l;i=i+1;

}

}

*r=k;

return (p);

}

int max (int t[10][10])

{

int t=0;

if (T[0][0]>t[1][0])

T=T[0][0];

else t=t[1][0];

if (T<t[2][0])

T=T[2][0];

return t;

}

int E1 (int t[10][10])

{

if (T[0][1]==t[1][1]&&t[1][1]==t[2][1])

return 1;

Else

return 0;

}

int E2 (int t[10][10])

{

int q=0;

if (((Max (T[10][10))-1)

==t[0][0]| | (Max (t[10][10])-1)

==t[1][0]| | (Max (t[10][10])-1)

==t[2][0]) && ((Max (T[10][10))-2)

==t[0][0]| | (Max (t[10][10])-2)

==t[1][0]| | (Max (t[10][10])-2)

==t[2][0]))

if (Q=max (t[][10]))

return 1;

Else

return 0;

}

int E3 (int t[10][10])

{

if (T[0][0]==t[1][0]==t[2][0])

return 1;

Else

return 0;

}

int E4 (int t[10][10])

{

if (T[0][0]==t[1][0]&&t[0][0]!=t[2][0])

return 1;

else if (t[0][0]==t[2][0]&&t[0][0]!=t[1][0])

return 1;

else if (t[1][0]==t[2][0]&&t[1][0]!=t[0][0])

return 1;

Else

return 0;

}

void Main ()

{

int times=0,e1=0,e2=0,e3=0,e4=0,e5=0;

int a[10][10],b[10][10];

int r1=2,r2=3;

printf (" Please enter the number of games \ n");

scanf ("%d", x);

for (int j=0;j<times;j++)

{

for (int i=0;i<3;i++)

{

A[I][0]=RABL (1,13,&R1);

A[I][1]=RABL (14,17,&R2);

B[I][0]=RABL (1,13,&R1);

B[I][1]=RABL (14,17,&R2);

}

if (E1 (a[][10]) >e1 (b[][10]))

{

e1++;

printf ("A wins, flush \ n");

}

else if (E1 (a[][10]) <e1 (b[][10]))

{

e1++;

printf ("B win, flush \ n");

}

else if (E1 (a[][10]) ==e1 (b[][10]) &&e1 (b[][10]) ==1)

{

e1++;

if (Max (a[][10]) >max (b[][10]))

printf ("A wins, flush \ n");

Else

printf ("B win, flush \ n");

}

else if (E2 (a[][10]) >e2 (b[][10]))

{

e2++;

printf ("A win, shun son \ n");

}

else if (E2 (a[][10]) <e2 (b[][10]))

{

e2++;

printf ("B win, shun son \ n");

}

else if (E2 (a[][10]) ==e2 (b[][10]) &&e2 (b[][10]) ==1)

{

e2++;

if (Max (a[][10]) >max (b[][10]))

printf ("A win, shun son \ n");

Else

printf ("B win, shun son \ n"); }  

else if (E3 (a[][10]) >e3 (b[][10]))

{

e3++;

printf ("A win, same point \ n");

}

else if (E3 (a[][10]) <e3 (b[][10]))

{

e3++;

printf ("B win, same point \ n");

}

else if (E3 (a[][10]) ==e3 (b[][10]) &&e3 (b[][10]) ==1)

{

e3++;

if (Max (a[][10]) >max (b[][10]))

printf ("A win, same point \ n");

Else

printf ("B win, same point \ n");

}

else if (E4 (a[][10]) >e4 (b[][10]))

{

e4++;

printf ("A wins, pair \ n");

}

else if (E4 (a[][10]) >e4 (b[][10]))

{

e4++;

printf ("B wins, pair \ n");

}

else if (E4 (a[][10]) ==e4 (b[][10]) &&e4 (b[][10]) ==1)

{

e4++;

if (Max (a[][10]) >max (b[][10]))

printf ("A wins, pair \ n");

Else

printf ("B wins, pair \ n");

}

Else

{

if (Max (a[][10]) >max (b[][10]))

printf ("A win, no- brand \ n");

Else

printf ("B win, no- brand \ n");

}

}

printf (" flush wins the probability of %d\n,

The probability of %d\n winning is

The probability of winning the same point is %d\n,

The probability of a pair winning is %d\n,

No-brand win probability for %d\n "

, e1/times,e2/times,e3/times,e4/times,e5/times);

}

The fifth chapter of the title industry

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.