當前位置:首頁 » 操作系統 » 撲克牌游戲源碼

撲克牌游戲源碼

發布時間: 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;

}
自己電腦上測試可以。。求採納。

熱點內容
圖片上傳功能java 發布:2024-10-07 10:14:18 瀏覽:128
rc4c語言實現 發布:2024-10-07 10:08:34 瀏覽:407
為什麼steam每天登錄都要輸密碼 發布:2024-10-07 10:08:33 瀏覽:436
電腦軟體連接不到伺服器怎麼解決 發布:2024-10-07 10:04:07 瀏覽:923
pubg如何換伺服器圖解 發布:2024-10-07 10:04:06 瀏覽:320
androidstudio異常 發布:2024-10-07 09:50:48 瀏覽:471
視頻緩存轉mp4 發布:2024-10-07 09:35:37 瀏覽:27
Java的腳本語言有哪些 發布:2024-10-07 09:27:43 瀏覽:876
如何使用香港伺服器 發布:2024-10-07 09:01:37 瀏覽:916
對戰平台搭建cs伺服器 發布:2024-10-07 09:00:16 瀏覽:528