当前位置:首页 » 操作系统 » html5扑克源码

html5扑克源码

发布时间: 2022-06-01 20:44:32

㈠ 24点游戏C++程序源代码

这是个算24点的程序,很像c++的一段代码#include <iostream>
#include <sys/timeb.h>
#include <vector>
#include <string>
#include <stdio.h>using std::vector;
using std::string;
using namespace std;class Node
{
public:
enum OpType
{
UNARY, PLUS, SUB, SUB2, MUL, DIV, DIV2
}; double& value(){ return value_; }
double value() const { return value_; } bool Add() { op_ = PLUS; value_ = left_->value_ + right_->value_; return true; }
bool Sub() { op_ = SUB; value_ = left_->value_ - right_->value_; return true; }
bool Sub2() { op_ = SUB2; value_ = right_->value_ - left_->value_; return true; }
bool Mul() { op_ = MUL; value_ = left_->value_ * right_->value_; return true; }
bool Div() { if(right_->value_==0)return false; op_ = DIV; value_ = left_->value_ / right_->value_; return true; }
bool Div2() { if(left_->value_==0)return false; op_ = DIV2; value_ = right_->value_ / left_->value_;return true; } Node( double d = 0 )
: left_(0), right_(0), op_(UNARY), value_(d)
{ }
Node( Node* l, Node *r )
: left_(l), right_(r), op_(UNARY), value_(0)
{ } string getExpr()
{
if( op_ == UNARY )
{
char buf[32];
return "";
} string str;
switch( op_ )
{
case PLUS:
case SUB:
case MUL:
case DIV:
str += "(";
str += left_->getExpr();
str += " +--*//"[op_];
str += right_->getExpr();
str += ")";
break;
case SUB2:
case DIV2:
default:
str += "(";
str += right_->getExpr();
str += " +--*//"[op_];
str += left_->getExpr();
str += ")";
}
return str;
} double value_;
OpType op_;
Node *left_;
Node *right_;
};template<unsigned int L>
bool query( double target, Node** cand, string& expr )
{
for( unsigned int k=0; k<L-1; ++k )
{
Node* newcand[L-1];
for( unsigned int j=k+1; j<L; ++j )
{
for( unsigned int i=k+1; i<j; ++i )
{
if( cand[i]->value() == cand[j]->value() )
continue;
} Node node( cand[k], cand[j] );
Node **pNode = newcand;
for( unsigned int i=0; i<L; ++i )
{
if( i!=k && i!=j )
*pNode++ = cand[i];
} newcand[L-2] = &node; if( node.Add() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Sub() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Sub2() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Mul() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Div() && query<L-1>( target, newcand, expr ) )
return true;
if( node.Div2() && query<L-1>( target, newcand, expr ) )
return true;
}
}
return false;
}template<>
bool query<1>( double target, Node** cand, string& expr )
{
double diff = target - cand[0]->value();
if( diff < 0.000001 && diff > -0.000001 )
{
//expr = cand[0]->getExpr();
return true;
}
return false;
}int main( int argc, char** argv)
{
const int LEN = 4;
if( argc != LEN+1 )
{
exit( -1 );
} double target = 24; Node nodes[LEN];
Node *cands[LEN];
for( int k=0; k<LEN; ++k )
{
int i = atoi( argv[k+1] );
if( i == 0 )
{
printf( "I don't like ZERO. Sorry!\n" );
exit( -1 );
}
nodes[k].value() = i;
cands[k] = &nodes[k];
} string expr;
if( query<LEN>( target, cands, expr ) )
printf( "%s\n", expr.c_str() );
else
printf( "fail!\n" ); return 0;
}

㈡ VB/vb.net编程 扑克牌

'以下是我做的图片拼算24的游戏,可供你参考
Option Explicit
Enum CARD_DRAW
CARD_DRAW_FACE
CARD_DRAW_BACK
CARD_DRAW_INVERT
End Enum
Private Declare Function cdtInit Lib "Cards.dll" ( _
dx As Long, dy As Long) As Long
Private Declare Function cdtDraw Lib "Cards.dll" (ByVal hDC As Long, _
ByVal X As Long, ByVal Y As Long, ByVal iCard As Long, _
ByVal iDraw As Long, ByVal Clr As Long) As Long
Private Declare Function cdtTerm Lib "Cards.dll" () As Long
Dim picDraw As PictureBox
Dim Cwidth&, Cheight&
Dim Card&(52)
Dim bgColor&
Dim strOps$, NumOps&, intCard&, CW&(3), strTag$(10)

'初始化处理
Private Sub Form_Initialize()
Dim i&
Randomize
strTag(7) = "+"
strTag(8) = "-"
strTag(9) = "×"
strTag(10) = "÷"
'动态添加控件并返回一个对该控件的引用。
Set picDraw = Controls.Add("VB.PictureBox", "picDraw")
picDraw.AutoRedraw = True
picDraw.BorderStyle = 0
picDraw.ScaleMode = 3
picDraw.BackColor = BackColor
picDraw.Width = 71
picDraw.Height = 96
picDraw.Visible = True
picDraw.Left = 400
'加载扑克牌到控件
cdtInit Cwidth, Cheight
For i = 0 To 51
Card(i) = i
Load imgCard(i + 4)
cdtDraw picDraw.hDC, 0, 0, Card(i), CARD_DRAW_FACE, bgColor
imgCard(i + 4) = picDraw.Image
Next
Load imgCard(56)
i = Int(Rnd * 15)
Select Case i
Case 0 To 2
cdtDraw picDraw.hDC, 0, 0, 52 - i * i * 0.5 + 2.5 * i, CARD_DRAW_FACE, bgColor
Case 3 To 14
cdtDraw picDraw.hDC, 0, 0, 51 + i, CARD_DRAW_BACK, bgColor
End Select
imgCard(56) = picDraw.Image
cdtTerm
'画帮助屏幕
picDraw.Width = 375
picDraw.Height = 346
picDraw.Picture = Picture
picDraw.CurrentX = 52
picDraw.CurrentY = 14
picDraw.Print "分步算式 运算符 分步算式"
picDraw.Line (332, 70)-(362, 100), vbWhite, BF
For i = 0 To 3
picDraw.Line (i * 80 + 8, 40)-(i * 80 + 79, 136), , B
Next
picDraw.CurrentX = 24
picDraw.CurrentY = 78
picDraw.Print "扑克牌 扑克牌 扑克牌 扑克牌 发牌"
picDraw.Line (20, 150)-(212, 166), vbWhite, BF
picDraw.CurrentX = 24
picDraw.CurrentY = 153
picDraw.Print "编辑算式或分步算式:数 运算符 数 算式测试"
picDraw.CurrentX = 16
picDraw.CurrentY = 194
picDraw.Print "算式由三个分步算式编辑而成,数包括扑克牌和分步算式."
picDraw.CurrentX = 16
picDraw.CurrentY = 216
picDraw.Print "分步算式参与运算时自动添加括号,算式编辑后可以测试."
picDraw.CurrentX = 16
picDraw.CurrentY = 238
picDraw.Print "如果你认为没有算式,则跳过算式编辑直接进行测试即可."
picDraw.Line (4, 320)-(370, 338), vbWhite, BF
picDraw.CurrentX = 16
picDraw.CurrentY = 323
picDraw.Print "图拼24--你只需用鼠标操作图片编辑算式即可,简单方便,好看好玩."
imgShowHelp = picDraw.Image
picDraw = Nothing
'洗牌
mixCard
ClsExpression
End Sub

'4张扑克牌+-*/算24
Private Sub Count24()
Dim a#(3), i&, b$(3)
List1.Clear
For i = 0 To 3
a(i) = Val(strTag(i))
b(i) = a(i)
Next
If Is24(a, b, 4) Then
Else
List1.AddItem "没有算式"
End If
End Sub

'取算术运算值
Private Function Sum(n1#, n2#, f) As Double
Select Case f
Case 1: Sum = n1 + n2
Case 2: Sum = n1 - n2
Case 3: Sum = n1 * n2
Case 4: If n2 Then Sum = n1 / n2 Else Sum = 1
End Select
End Function

'列算式
Private Function ShowSum(n1$, n2$, f)
ShowSum = n1 & Mid("+-×÷", f, 1) & n2
End Function

'递归算24
Private Function Is24(a#(), b$(), i&) As Boolean
Dim c#(2), ff&, ii&, jj&, kk&, nb&, d$(3), iCount&
If i = 2 Then
For ff = 1 To 4
equal a(0), a(1), ff, b(0), b(1), Is24
equal a(1), a(0), ff, b(1), b(0), Is24
Next
Else
For ii = 0 To i - 2
For jj = ii + 1 To i - 1
nb = 1
For kk = 0 To i - 1
If kk <> ii And kk <> jj Then c(nb) = a(kk): d(nb) = b(kk): nb = nb + 1
Next
For ff = 1 To 4
c(0) = Sum(a(ii), a(jj), ff)
d(0) = "(" & ShowSum(b(ii), b(jj), ff) & ")"
If Is24(c, d, i - 1) Then Is24 = True
c(0) = Sum(a(jj), a(ii), ff)
d(0) = "(" & ShowSum(b(jj), b(ii), ff) & ")"
If Is24(c, d, i - 1) Then Is24 = True
Next
Next
Next
End If
End Function

'两个数运算是否为24,b0$, b1$分别为Num1#, Num2#的字符串表达式
Private Sub equal(Num1#, Num2#, Ops&, b0$, b1$, Is24 As Boolean)
Dim iCount&
If Sum(Num1, Num2, Ops) = 24 Then
strOps = ShowSum(b0, b1, Ops)
For iCount = 0 To List1.ListCount - 1
If InStr(List1.List(iCount), strOps) Then Exit For
Next
If iCount = List1.ListCount Then List1.AddItem Format((iCount + 1), "@@@@") & ": " & strOps
Is24 = True
End If
End Sub

'洗牌(从52张扑克牌中随机抽出4张)
Private Sub mixCard()
Dim i&, j&, k&
For i = 0 To 3
j = Fix(Rnd * (52 - i) + i)
k = Card(j)
Card(j) = Card(i)
Card(i) = k
Next
End Sub

'清空算式处理
Sub ClsExpression()
Dim i&, X&, w&
For i = 0 To 3
strTag(i) = Card(i) \ 4 + 1
imgNum(i) = imgNumOps(strTag(i) - 1)
imgCard(i) = imgCard(Card(i) + 4)
CW(i) = 0
Next
strTag(4) = ""
imgExpression(0) = Nothing
strTag(5) = ""
imgExpression(1) = Nothing
strTag(6) = "没有算式"
imgAnswer = Nothing
picDraw.Visible = False
picDraw.Cls
picDraw.Width = imgAnswer.Width
picDraw.Height = imgAnswer.Height
picDraw.CurrentX = 126
picDraw.CurrentY = 2
picDraw.Print "没有算式?"
imgAnswer = picDraw.Image
NumOps = 0
List1.Clear
List1.Visible = False
picDraw = Nothing
End Sub

'显示帮助
Private Sub imgHelp_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgHelp = Nothing
imgShowHelp.Visible = True
List1.Tag = List1.Visible
picDraw.Tag = picDraw.Visible
picDraw.Visible = False
List1.Visible = False
End Sub

Private Sub imgHelp_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgHelp = imgPic(0)
End Sub

Private Sub imgOperator_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
imgOperator(Index).Top = 16
End Sub

'选取运算符列入算式
Private Sub imgOperator_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
imgOperator(Index).Top = 12
If (NumOps Mod 3 - 1) Or NumOps > 8 Then Exit Sub
strTag(6) = strTag(6) & strTag(7 + Index)
NumOps = NumOps + 1
CW(3) = CW(2) + 20
UnitePic imgAnswer, imgOperator(Index), 0
imgAnswer = picDraw.Image
CW(2) = CW(3)
End Sub

'隐藏帮助
Private Sub imgShowHelp_Click()
imgShowHelp.Visible = False
picDraw.Visible = CBool(picDraw.Tag)
List1.Visible = CBool(List1.Tag)
End Sub

'发牌
Private Sub imgShuffle_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgShuffle = Nothing
mixCard
ClsExpression
End Sub

Private Sub imgShuffle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgShuffle = imgPic(1)
End Sub

'清空算式
Private Sub imgCls_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgCls = Nothing
End Sub

Private Sub imgCls_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgCls = imgPic(2)
ClsExpression
End Sub

'显示所有算式答案
Private Sub imgQuery_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgQuery = Nothing
If NumOps = 9 Or picDraw.Visible = True Then List1.Visible = True
End Sub

Private Sub imgQuery_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
imgQuery = imgPic(3)
End Sub

'移动指牌器
Private Sub imgNum_Click(Index As Integer)
intCard = Index
imgPoint.Left = imgNum(Index).Left - 11
End Sub

'随意数字选取牌
Private Sub imgNumOps_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
shpBorder.Visible = True
If Index < 9 Then shpBorder.Left = imgNumOps(Index).Left - 6 Else shpBorder.Left = imgNumOps(Index).Left
strTag(intCard) = Index + 1
imgNum(intCard) = imgNumOps(Index)
imgNum_Change intCard
intCard = (intCard + 1) Mod 4
imgPoint.Left = imgNum(intCard).Left - 11
End Sub

Private Sub imgNumOps_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
shpBorder.Visible = False
End Sub

'选牌后处理
Private Sub imgNum_Change(Index&)
Dim i&
If strTag(Index) = Card(Index) \ 4 + 1 Then Exit Sub
Do
Card(Index) = (strTag(Index) - 1) * 4 + Int(Rnd * 4)
For i = 0 To 3
If Card(Index) = Card(i) And Index <> i Then Exit For
Next
If i = 4 Or (i = 3 And Index = 3) Then Exit Do
Loop
imgCard(Index) = imgCard(Card(Index) + 4)
ClsExpression
End Sub

'选取扑克牌列入算式
Private Sub imgCard_Click(Index As Integer)
If imgCard(Index) = imgCard(56) Then Exit Sub
If strTag(6) = "没有算式" Then strTag(6) = "": imgAnswer = Nothing: picDraw.Visible = False
If NumOps Mod 3 = 1 Then Exit Sub
strTag(6) = strTag(6) & strTag(Index)
If strTag(Index) < 10 Then CW(3) = CW(2) + 12 Else CW(3) = CW(2) + 24
UnitePic imgAnswer, imgNumOps(strTag(Index) - 1), 0
imgCard(Index) = imgCard(56)
expression
End Sub

'算式结果处理
Private Sub expression()
Dim i&
NumOps = NumOps + 1
If NumOps Mod 3 = 0 Then
If NumOps = 9 Then Exit Sub
If strTag(4) <> "" Then i = 1
strTag(4 + i) = strTag(6)
CW(2) = 0
UnitePic imgExpression(i), imgAnswer, (imgAnswer.Width - CW(3)) \ 2
CW(i) = CW(3)
CW(2) = 0
strTag(6) = ""
imgAnswer = Nothing
picDraw = imgAnswer
End If
End Sub

'选取运算结果列入算式
Private Sub imgExpression_Click(Index As Integer)
If strTag(4 + Index) = "" Then Exit Sub
If NumOps Mod 3 = 1 Then Exit Sub
strTag(6) = strTag(6) & "(" & strTag(4 + Index) & ")"
CW(3) = CW(2) + 12
UnitePic imgAnswer, imgOperator(4), 0
CW(3) = CW(2) + CW(Index)
UnitePic imgAnswer, imgExpression(Index), (imgExpression(Index).Width - CW(Index)) \ 2
CW(3) = CW(2) + 12
UnitePic imgAnswer, imgOperator(5), 0
strTag(4 + Index) = ""
imgExpression(Index) = LoadPicture("")
expression
End Sub

'验证算式是否正确
Private Sub imgAnswer_Click()
If picDraw.Visible = True Then Exit Sub
If strTag(6) = "没有算式" Or NumOps = 9 Then Validate strTag(6)
End Sub

'算式验证
Private Sub Validate(Ops$)
Dim i&
Count24
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), Ops) Then Exit For
Next
picDraw.Width = 54
picDraw.Height = imgAnswer.Height
picDraw.CurrentX = 2
picDraw.CurrentY = 2
picDraw.ForeColor = vbBlue
If i = List1.ListCount Then
picDraw.Print "再想一想"
Else
picDraw.Print "你算对了"
List1.Selected(i) = True
End If
picDraw.ForeColor = vbBlack
picDraw.Move 260, 150
picDraw.Visible = True
End Sub

'图片合并居中(img2拼接到img1右边):img1剪切宽度拼接前CW(2),拼接后CW(3);img2剪切左边距img2W
Sub UnitePic(img1 As Image, img2 As Image, img2W&)
Dim w1&
w1 = img1.Width
picDraw.Cls
picDraw.Width = w1
picDraw.Height = img1.Height
If img1 Then picDraw.PaintPicture img1, (w1 - CW(3)) \ 2, 0, , , (w1 - CW(2)) \ 2
If img2 Then picDraw.PaintPicture img2, (w1 - CW(3)) \ 2 + CW(2), 0, , , img2W
img1 = picDraw.Image
CW(2) = CW(3)
End Sub

'删除动态添加的控件
Private Sub Form_Unload(Cancel As Integer)
Controls.Remove picDraw
End Sub

㈢ 易语言用画板制作扑克牌游戏手牌

画板得用两个 来回复制比较麻烦 建议还是用动画框吧 动画框比较方便 可以创建扑克牌物体然后置扑克牌的层次和位置 还可以加上一些动画效果 比如洗牌 发牌

㈣ 如何用VB做记牌器

转片贴子,希望会对你有所帮助
“记牌器是怎样编写出来的?”
该文章的网址是:http://hi..com/whsangda
作者用VB语言所编写的最新QQ斗地主记牌器V9.30在天空软件站已经被超过四万五千多人下载使用,记牌器的下载网址是:
http://www2.skycn.com/soft/27872.html

㈤ 54张扑克牌,留5张底牌,其它分给四个人,求代码实现我图片上的内容

我这里有个模拟发牌52张的代码,稍微改改就可以了,供你参考

#include<stdio.h>
#include<time.h>
#include<stdlib.h>
intmain(void)
{
intaim,i;
intpoker[52]={0};/*已发的牌在数组中,初始状态为0,表示没发过,置为1表示已发过,避免重复发放*/

srand((unsigned)time(NULL));/*随机数初始化*/

/*产生一个随机数0-51,并保存到aim变量中*/
aim=rand()%52;

/*模拟发不含大小王牌的扑克牌,
将生成的随机数映射为每张扑克牌。
按照花色(梅花、方块、红桃、黑桃)和大小(2~10、J、Q、K、A)顺序进行映射。
映射规则如下:
梅花:0-12
方块:13-25
红桃:26-38
黑桃:39-51
*/


/*以下模拟发52张牌,可以根据需要修改循环次数发任意张*/
for(i=1;i<=52;i++)
{
aim=rand()%52;
/*已发的牌在数组中置为1,避免重复发放*/
while(poker[aim]==1)
{
aim=rand()%52;
}
poker[aim]=1;

printf(" 第%2d张牌:",i);
switch(aim/13)
{
case0:
printf("梅花");
break;
case1:
printf("方块");
break;
case2:
printf("红桃");
break;
case3:
printf("黑桃");
break;
default:break;
}
switch(aim%13+1)
{
case2:
case3:
case4:
case5:
case6:
case7:
case8:
case9:
case10:
printf("%2d",aim%13+1);
break;
case1:
printf("A");
break;
case11:
printf("J");
break;
case12:
printf("Q");
break;
case13:
printf("K");
break;
default:break;
}
}
return0;
}

㈥ 求:纸牌游戏源代码 急需!!

非常简单的记忆类游戏阿,写好了个简单框架,把card类替换为你的素材就可以了,需要的话可以给你发源码

㈦ 三重德州扑克源码连不上电脑怎么办

会自动连接的

㈧ 求德州扑克服务器端源码 或者核心算法(计算谁的牌大)也行

“完全充电”是指所有剩下的筹码手柄上的一次赌注。一个人没有足够的筹码跟进时,你可以打赌,所有剩下的筹码。在“无极限”的游戏,“全”是一种策略。一旦有人推锅将割让“一锅端”。扑克奖金边缘池,其中包含只有数人开始追随他的手“”到目前为止,这个时候黄金注入。如果这名男子猛的后向董事会仍在继续,人走开“一锅端”的权利,但不能赢得其他玩家的下跌后,他猛的“锅”奖金。在这种情况下,秒针会赢得一个强大推去后,也就是剩余的奖金。

热点内容
2019速腾买什么配置好 发布:2025-01-11 01:35:07 浏览:828
博越存储异常 发布:2025-01-11 01:24:31 浏览:916
我的世界还原中国服务器版图 发布:2025-01-11 01:18:45 浏览:382
pythonopenasfile 发布:2025-01-11 01:17:06 浏览:971
hbasejavaapi 发布:2025-01-11 01:11:09 浏览:744
我的世界pe版饥饿服务器 发布:2025-01-11 01:09:39 浏览:485
异构数据库数据同步 发布:2025-01-11 01:09:04 浏览:957
c语言三角波 发布:2025-01-11 01:02:11 浏览:78
php正则转义 发布:2025-01-11 01:00:03 浏览:691
手拉的箱包上的密码锁一般是多少 发布:2025-01-11 00:59:55 浏览:8