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

扑克牌游戏源码

发布时间: 2022-05-06 02:02:51

A. 急需一段用纯java语言编的21点纸牌游戏的源代码

我给你写,
但是报酬是1000块

B. 高分求java纸牌游戏源代码

Araneid 蜘蛛纸牌游戏

详细参考工程主页: http://pub.idr.gov.cn/jid/projects/araneid

源代码下载(或附件):
http://pub.idr.gov.cn/jid/projects/araneid/download/araneid-1.1.0-src.zip

二进制下载:
http://pub.idr.gov.cn/jid/projects/araneid/download/araneid-1.1.0.zip

运行时请先解压缩,然后执行 classes 目录下的 start.bat

C. 高分求一C++小游戏源代码 急急急~~

21点扑克牌游戏

#include<ctime>
//#include<stdio>
#include<iostream>
//#include<stdlib>
#include<conio.h>
using namespace std;
//定义扑克类
class game
{
private:
int wins,lose,draw,money;
int bet,playerturns,cputurns;
float player,cpu,card;//此处CARD在和BET交换数据的时候会有警告,可多定义一个INT型避免。
char flag;
public:
game();
void results(float player,float cpu,int bet,int &money,int &draw,int &wins,int &lose);
void wait(int milli);
void sign();
void special(float &player,float &cpu);
void rules();
void pause();
float random(long hign,long low);
void print(int wins,int lose,int draw,int money);
void replay(char &flag);
void hit(float &total);
void results(float player,int cpu,int bet,int &money,int &draw,int &win,int &lose);
void BET(int &bet,int &money);
void deal(float &player,float &cpu,int &playerturns,int &cputurns);
void deal2(float &player,float &cpu,int &playerturns,int &cputurns);
void ask();
};
//---------------------------------------------------------------------
//完成虚构函数
game::game()
{
wins=0;
lose=0;
draw=0;
money=0;
player=0.0;
cpu=0.0;
bet=0;
playerturns=0;
cputurns=0;
card=0;
flag='a';
}
//---------------------------------------------------------------------
void game::rules()
{
cout<<"\t*********************************************************"<<endl;
cout<<"\t*\t\t欢迎玩这个扑克21点游戏\t\t\t*"<<endl;
cout<<"\t*\t\t\t规则如下\t\t\t*"<<endl;
cout<<"\t*\t\t一:你不能超过5张牌.\t\t\t*"<<endl;
cout<<"\t*\t\t二:可以追加赌注.\t\t\t*"<<endl;
cout<<"\t*\t\t三:同意按y.\t\t\t\t\*"<<endl;
cout<<"\t*********************************************************"<<endl;
cout<<"\t\t\t";
pause();//此处暂停几秒
ask();
}
//---------------------------------------------------------------------
void game::ask()
{
cout<<endl<<endl;
cout<<"\t\t\t你想玩这个游戏么?"<<endl;
cin>>flag;
if((flag=='y')||(flag=='Y')) //判断是否进入游戏
{
cout<<"\t\t\t你将有100元开始这个游戏"<<endl;
money=100;//设置最初赌注
cout<<"\t\t\t";
pause();
}
else exit(1);
BET(bet,money);
deal(player,cpu,playerturns,cputurns);//开始处理
}
//---------------------------------------------------------------------
void game::BET(int &bet,int &money)
{
int sign;
system("cls");
if(money<=0)
{
cout<<"\t\t\t你已经没有赌注了,请关闭后重新开始"<<endl;
exit(1);
}
cout<<"\t\t\t你现在有:"<<money<<"$赌注"<<endl;
cout<<"\t\t\t你想下注多少:";
do{ //判断输入赌注是否正确
sign=0;
cin>>bet;
if((bet<0)&&(bet*-1<=money))
{
bet=bet*-1;
break;
}
else if((bet>0)&&(bet<=money))
break;
else
{
cout<<"输入错误,请重新输入:";
sign=1;
}
}while(sign=1);
money=money-bet;
}

//---------------------------------------------------------------------
void game::deal(float &player,float &cpu,int &playerturns,int &cputurns)
{
float playercard1,playercard2,cpucard1,cpucard2;
playerturns=2;
cputurns=2;
playercard1=random(13,1); //开始利用随机数分牌
cout<<"\n\t\t\t正在处理中"<<endl;
wait(350);
playercard2=random(13,1);
wait(150);
cpucard1=random(13,1);
wait(350);
cpucard2=random(13,1);
if(playercard1>=10)
{
playercard1=0.5;
}
if(playercard2>=10)
{
playercard2=0.5;
}
if(cpucard1>=10)
{
cpucard1=0.5;
}
if(cpucard2>=10)
{
cpucard2=0.5;
}
player=playercard1+playercard2;
cpu=cpucard1+cpucard2;
cout<<"\t\t\t你的点数为:"<<player<<endl<<endl;
cout<<"你的两张牌是:";
cout<<"["<<playercard1<<"]";
cout<<"["<<playercard2<<"]";
cout<<endl;
cout<<"\t\t\t电脑有一张"<<cpucard1<<"显示"<<endl;
cout<<endl;
cout<<"电脑的牌是:";
cout<<"[*]"<<"["<<cpucard1<<"]"<<endl;
deal2(player,cpu,playerturns,cputurns);//调用发牌函数
}
//---------------------------------------------------------------------
void game::deal2(float &player,float &cpu,int &playerturns,int &cputurns)
{
do{
cout<<"\t\t\t你想继续要牌么?";
cin>>flag;
if(((flag=='o')||(flag=='O'))&&(playerturns<5)) //判断是否高级玩家
{
do
{
card=random(13,1);
if(card>10)
{
card=0.5;
}
cout<<"\t\t\t下张牌是:"<<card<<endl; //显示下张牌
cout<<"\t\t\t你想要这张牌么?(输入p继续要牌)"<<endl;
cin>>flag;
if((flag=='p')||(flag=='P'))
{
playerturns++;
player=player+card;
cout<<"\t\t\t你现在的点数是:"<<player<<endl;
}
if(playerturns>=5)
{
cout<<"\t\t\t\n你的牌已经到了五张,不能再要牌了"<<endl;break;
}
}while(flag=='p');
}
else if((flag=='y')||(flag=='Y')) //此处设置普通玩家
{
playerturns++;
if(player>21)
{
cout<<"\t\t\t你暴庄了,你输了";
lose++;
replay(flag);
}
if(playerturns>5)
{
cout<<"\t\t\t你的牌已经到了五张,不能再要牌了"<<endl;break;
}
else if((playerturns<6)&&((flag=='y')||(flag=='Y')))
{
cout<<endl;
hit(player);
}
}

}while((flag=='y')||(flag=='Y'));
cout<<"\t\t\t你想追加赌注么?"<<endl; //问是否需要追加赌注
cin>>flag;
if((flag=='y')||(flag=='Y'))
{
cout<<"\t\t\t请输入你想追加的赌注:";
do{
cin>>card;
if(money==0) //判断是否能追加赌注
{
cout<<"\t\t\t你已经没有赌注了,电脑开始要牌。"<<endl;
break;
}
if((card)>money)
{
cout<<"\t\t\t你的赌注不够。"<<endl;
cout<<"\t\t\t请输入0到"<<money<<"之间的数字:"<<endl;
}
}while((card)>money);
bet=bet+card;
money=money-card;
}
for(;(cpu<16)&&(cputurns<5);cputurns++) //给电脑发牌
{
cout<<endl;
cout<<"\t\t\t电脑要了一张牌"<<endl;
hit(cpu);
if(cpu>21)
{
cpu=cpu-card;
break;
}
}
cout<<endl;
cout<<endl;
cout<<"\t\t\t电脑的牌点数为:"<<cpu<<endl;
cout<<"\t\t\t你的点数为:"<<player<<endl;
cout<<endl;
if(((player<=21)&&(cpu<=21))||(playerturns==6)||(cputurns==5)) //特殊判断
{
special(player,cpu);
}
results(player,cpu,bet,money,draw,wins,lose);
replay(flag);
print(wins,lose,draw,money);
cout<<endl;
}

//---------------------------------------------------------------------
void game::hit(float &total) //分牌函数
{
float card;
card=random(13,1);
if(card>=10)
{
card=0.5;
}
total=total+card;
cout<<"\t\t\t要的牌是:"<<card<<endl;
cout<<"\t\t\t总共的点数是:"<<total<<endl;
}
//---------------------------------------------------------------------
void game::pause()
{
cout<<"按任意键继续"<<endl;
getch();
}
//---------------------------------------------------------------------
void game::wait(int milli)
{
clock_t start; //调用TIME.H内函数
start=clock();
while((clock()-start)<milli)
;
}
//---------------------------------------------------------------------
float game::random(long high,long low) //得到随机数
{
float ran;
srand((unsigned)time(NULL));
ran= rand()%(high-(low-1))+low;
return(ran);
}
//---------------------------------------------------------------------
void game::replay(char &flag)
{
cout<<"\n\t\t\t你想继续玩这个游戏么:";
cin>>flag;
while((flag=='y')||(flag=='Y')) //此处设置游戏循环
{
BET(bet,money);
deal(player,cpu,playerturns,cputurns);
}
print(wins,lose,draw,money);
}
//---------------------------------------------------------------------
void game::print(int wins,int lose,int draw,int money) //输出结果
{
cout<<"\t\t\t赢:"<<wins<<endl;
cout<<"\t\t\t输:"<<lose<<endl;
cout<<"\t\t\t和:"<<draw<<endl;
cout<<"\t\t\t剩余钱数:"<<money<<endl;
sign();
}
//---------------------------------------------------------------------
void game::results(float player,float cpu,int bet,int &money,int &draw,int &wins,int &lose)
{
if(cpu==player) //输出结果
{
cout<<"\t\t\t点数相同,庄家赢"<<endl;
draw++;
}
if(player>21)
{
cout<<"\t\t\t你暴庄了,加油"<<endl;
lose++;
}
else
{
if(cpu<player)
{
cout<<"\n\t\t\t恭喜,你赢了";
money=money+(bet*2);
wins++;
}
}
if(cpu>21)
{
cout<<"\t\t\t庄家加油"<<endl;
if(player<21)
{
cout<<"\n\t\t\t你赢了";
wins++;
money=money+(bet*2);
}
}
else
{
if(cpu>player)
{
cout<<"\t\t\t你输了"<<endl;
lose++;
}
}
}
//---------------------------------------------------------------------
void game::sign()
{
cout<<"\n\n\n\n\t\t\t新手第一次写,多多指教"<<endl;
exit(1);
}
//---------------------------------------------------------------------
void game::special(float &player,float &cpu)
/*如果要五张牌还不超过21点而对方没到五张牌,那就算赢.如果两个人都五张牌且都没
有超过21点,那点数小的赢.*/
{
if((player<=21)&&(cpu<=21)&&(playerturns==6)&&(cputurns<5))
{
cout<<"\n\t\t\t恭喜,你赢了";
money=money+(bet*2);
wins++;
}
if((player<=21)&&(cpu<=21)&&(playerturns<6)&&(cputurns==5))
{
cout<<"\t\t\t你输了"<<endl;
lose++;
}
if((player<=21)&&(cpu<=21)&&(playerturns==6)&&(cputurns==5))
{
if(player<cpu)
{
cout<<"\n\t\t\t恭喜,你赢了";
money=money+(bet*2);
wins++;
}
else
{
cout<<"\t\t\t你输了"<<endl;
lose++;
}
}
replay(flag);
}
//---------------------------------------------------------------------
void main()
{
game deck;
deck.rules();
}
//---------------------------------------------------------------------

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

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

E. 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

F. c语言程序设计扑克牌游戏

定义一个结构类型表示一张牌,结构包含3个成员,第一个成员char:取值2,3~K,A表示牌名字,第二个成员int:取值2~14表示牌真实大小。第三个成员:结构链表指针。
写一个初始化函数,定义52大小的结构数组,成员值初值分别和牌对应,遍历数组并将每个元素的链表指针依次指向下一个元素地址。这样得到一个初始链表。(相当于一盒新牌)
所有涉及随机数都用rand函数,洗牌分四份就是循环取随机数m=1~n,n是随循环自减,初值52,直到n变成0。每随一次循环就从初始链表中遍历取出对应第m个节点,并从初始链表中将这个节点断开(既前一个节点指针直接指向后一个节点指针)。每取13张就组成一个新的链表。这样获得4个新链表分别表示4个玩家。
最后出牌就是分别遍历自己的链表,利用循环取牌比较结构数值大小。(取出的牌要从链表断开和上面一样,你把取出节点写成独立函数就能反复使用)。

G. C语言程序设计课程设计扑克牌游戏,怎么做

#include<conio.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
int jisuan(int);
int comptotal;
char s1[]="A234567890JQK";
//char s2[4][5]={"红桃","黑桃","草花","方块"};
char s2[4]={3,4,5,6};
int poke[52];
int ch;
int win=0;
int computer[5],user[5];
int usertotal;
int users;
int k;
int main()
{ void xipai(int poke[]);
void ai();
int i,j;
////////////////////////////////////////////////////////上面是变量和声明
printf("\n这是简单的廿一点游戏:\n");
for(i=0;i<52;i++)
{
if(i%13==0)putchar('\n');
poke[i]=i;
printf("%c%c%c ",s2[i/13],s1[i%13]=='0'?'1':' ',s1[i%13]);
}
putchar('\n');

/////////////////////////////////////////////////////////主代码
k=0;
xipai(poke);
while(ch!=27)
{ comptotal=0;
usertotal=0;
if(k>=42)
{
printf("\n剩余牌数不足十张,重新洗牌");
xipai(poke);
k=0;
}

printf("\n\n\n\n\n\n\n\n新局开始:\n");
printf("现在共有牌%2d张\n",52-k);
if(win==0)
{
computer[0]=k++;
user[0]=k++;
printf("\n电脑做庄,要牌:");
ai();
}
else
{
printf("\n玩家做庄,要牌:\n\t回车要牌\n\t空格过牌");
user[0]=k++;
computer[0]=k++;
}

printf("\n玩家开始要牌:\n");
usertotal=jisuan(poke[user[0]]);
printf("%c%c%c 共%2d点\t",s2[poke[user[0]]/13],s1[poke[user[0]]%13]=='0'?'1':' ',s1[poke[user[0]]%13],usertotal);
users=0;
ch=1;
while(ch!=32&&users<4)
{
ch=getch();
switch(ch)
{
case 27:
goto end;
break;
case 32:
break;
case 13:
user[++users]=k;
usertotal+=jisuan(poke[user[users]]);
printf("\b\b\b\b\b\b\b\b\b%c%c%c 共%2d点\t",s2[poke[k]/13],s1[poke[k]%13]=='0'?'1':' ',s1[poke[k]%13],usertotal);

k++;
if(usertotal>=21)ch=32;
break;
default:
break;
}
}
if(win==1)
{
printf("\n电脑开始要牌:\n");
ai();
}
printf("\n\n\n玩家的点数是%2d",usertotal);
printf("\n电脑的点数是%2d",comptotal);
printf("\n\n本局结算:");
if(comptotal>21&&usertotal<=21)
{
printf("\n\n电脑爆牌了");
win=1;
printf("\n恭喜,你赢了");
}

if(usertotal>21&&comptotal<=21)
{
printf("\n\n你爆牌了");
printf("\n下次小心点");
win=0;
}
if(usertotal>21&&comptotal>21)
{
printf("\n\n你们两个,怎么都这么不小心啊,都撑死了还要吗");
}
if(usertotal<=21&&comptotal<=21)
{
if(usertotal>comptotal)
{
win=1;
printf("\n\n不错,你赢了");
}
else if(usertotal<comptotal)
{
win=0;
printf("\n\n撑死胆大的,饿死胆小的,没胆子,输了吧");
}
else
printf("\n\n平了,算你走运");
}
getch();
}
end:
return 0;
}
void xipai(int poke[])
{
int y,tmp,i,j;
for(j=0;j<7;j++)
for(i=0;i<52;i++)
{
srand(time(0));
y=rand()%10;
tmp=poke[i];
poke[i]=poke[(y*i*i)%52];
poke[(y*i*i)%52]=tmp;
}

}
///////////////////////////////////////////////子函数
void ai()
{
int i;
comptotal=jisuan(poke[computer[0]]);
printf("\n%c%c%c 共%2d点\t",s2[poke[computer[0]]/13],s1[poke[computer[0]]%13]=='0'?'1':' ',s1[poke[computer[0]]%13],comptotal);
for(i=0;i<4;i++)
{
if(comptotal<17)
{
computer[i+1]=k++;
comptotal+=jisuan(poke[computer[i+1]]);
printf("\b\b\b\b\b\b\b\b\b%c%c%c 共%2d点\t",s2[poke[computer[i+1]]/13],s1[poke[computer[i+1]]%13]=='0'?'1':' ',s1[poke[computer[i+1]]%13],comptotal);
}
}
}

int jisuan(int i)
{int dian;
switch(i%13)
{
case 0:
case 10:
case 11:
case 12:
dian=1;
break;
default:
dian=i%13+1;
}
return dian;
}

H. C++课程设计求救!!!21点扑克牌游戏代码!

首先准备配气正时装配的专用工具,一是凸轮轴正时的校正板;二是曲轴TDC正时的对正螺栓。 1.确保发动机在1号气缸上止点位置。 2.确保曲轴链轮键槽在11点钟位置1。 3.安装左链条的曲轴链轮。 4.安装左凸轮轴。确保进气凸轮轴正时标记与气缸盖上表面一起对正链节标记15。 确保排气凸轮轴正时标记在到气缸盖上表面90度处对正16。 5.安装左链条。将铜色链节与链轮标记15,16和17对正。 6.安装左链条导轨13和14。安装左张紧器12。拧紧螺栓18。 7.推动可动导轨靠着链条。拆下线夹11。 8.顺时针转动曲轴120度直到曲轴键槽在3点钟位置2。 9.安装右链条的曲轴链轮。 10.安装右凸轮轴。确保进气凸轮轴正时标记与气缸盖上表面一起对正链节标记19。 确保排气凸轮轴正时标记在到正气缸盖上表面90度处对正20。 11.安装右链条。将铜色链条线与链轮标记 19、20和21都对正。 12.安装右链条导轨7和8。安装右张紧器6。拧紧螺栓22。 13.推动可动导轨靠着链条。拆下线夹5。 14.将曲轴皮带轮螺栓拧紧至120牛顿·米。拧松360度。拧紧至47-53牛顿·米 85-95度。

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

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

J. c/c++扑克牌游戏

#include<iostream>

#include<string>

using namespace std;

struct puke

{

string str;

puke *next;

};

struct puke* creat(void)

{

int i;

struct puke *head,*p,*q;

p=new puke;

head=p;

q=p;

cin>>p->str;

for(i=0;i<25;i++)

{

q=p;

p=new puke;

cin>>p->str;

q->next=p;

}

q=q->next;

q->next=NULL;

return head;

}

struct puke* last(struct puke*head)

{

while(head->next!=NULL)

{

head=head->next;

}

return head;

}

/*void display(struct puke *head)

{

while(head!=NULL)

{

cout<<head->str;

head=head->next;

}

} */

int main()

{

puke *head1,*last1,*head2,*last2;

puke *p1,*p2,*q1,*q2;

int i,j=0,k=0,n=0,m;

bool flag;

head1=creat();

head2=creat();

p1=head1;

p2=head2;

last1=last(head1);

last2=last(head2);

// display(head1);

string str[52];

for(i=0;;i++)

{

if(i%2==0)

{

str[n]=p1->str;

p1=p1->next;

flag=0;

}

else

{

str[n]=p2->str;

p2=p2->next;

flag=1;

}

m=n;

cout<<str[n]<<endl;

n++;

for(j=0;j<m;j++)

{

if(str[m]==str[j])

{

k=m;

n=j;

// cout<<m<<" "<<k<<" "<<n<<" "<<flag<<endl;

if(flag==0)

{

for(j;j<=k;j++)

{

last1->next=q1;

q1=new puke;

q1->str=str[j];

last1=q1;

str[j]='0';

}

last1->next=NULL;

}

if(flag==1)

{

for(;j<=k;j++)

{

last2->next=q2;

q2=new puke;

q2->str=str[j];

last2=q2;

str[j]='0';

}

last2->next=NULL;

}

continue;

}

}

if(p1==NULL||p2==NULL)

{

break;

}

}

// cout<<i<<endl;

if(p1==NULL)

cout<<"Bob"<<endl;

else

cout<<"Alice"<<endl;

return 0;

}
自己电脑上测试可以。。求采纳。

热点内容
sql全角转半角 发布:2024-10-07 08:25:00 浏览:778
公众服务器配置是什么 发布:2024-10-07 08:17:11 浏览:492
为什么服务器贵吗 发布:2024-10-07 08:16:37 浏览:641
为什么服务器的引导分区会损坏 发布:2024-10-07 07:54:07 浏览:672
安卓社交源码 发布:2024-10-07 07:16:12 浏览:949
python两个list合并 发布:2024-10-07 07:12:02 浏览:870
迅雷文件夹加密 发布:2024-10-07 07:03:00 浏览:952
dns服务器地址是多少 发布:2024-10-07 06:53:42 浏览:176
论坛php程序 发布:2024-10-07 06:52:16 浏览:581
2005数据库恢复 发布:2024-10-07 06:21:49 浏览:381