各位C++老师,我下了一个斗地主的源程序,发现没有main的入口函数,我该从什么地方开始着手看?

各位C++老师,我下了一个斗地主的源程序,发现没有main的入口函数,我该从什么地方开始着手看?,第1张

你在vc环境下,点击edit-->find in file,工程选择你源码所在目录,搜索关键字就是main,下面的项目都不要选,然后点击find,查看一下结果

main函数是所有工程的入口函数,但有些地告答方颂友慧会把他封装起来,比如野答想WinMain,Win32等,名字不一定是什么,但肯定会带着一个main的

#include <time.h>

#include <iostream>

#include <string>

#include <vector>

enum em_CardClass_t

{

_CC_hearts = 0, // 红桃

_CC_Spade, //败扮 黑桃

_CC_Clubs, // 梅花

_CC_Diamonds, // 方块

_CC_King // 大小王

}

struct st_Card_t

{

em_CardClass_t _emCardClass

UINT _uCardIndex // _emCardClass为_CC_King时,有效取值[1,2]

// _emCardClass非_CC_King时,有效取值握旅[1,13]

}

using namespace std

void InitCard(vector<st_Card_t>&vtCard)

{

st_Card_t card

for( UINT i=0i<_CC_Kingi++ )

{

card._emCardClass = (em_CardClass_t)i

for( UINT j=1j<14j++ )

{

card._uCardIndex = j

vtCard.push_back(card)

}

}

card._emCardClass = _CC_King

card._uCardIndex = 1

vtCard.push_back(card)

card._uCardIndex = 2

vtCard.push_back(card)

}

// 分牌

void DealCard(vector<st_Card_t>&vtCard, vector<st_Card_t>&vtPlayer1,

vector<st_Card_t>&vtPlayer2, vector<st_Card_t>&vtPlayer3)

{

srand( (unsigned)time( NULL ) )

for( int i = 0i <51i++ )

{

int iCard = rand() % vtCard.size()

switch( i % 3 )

{

case 0:

vtPlayer1.push_back(vtCard[iCard])

break

case 1:

vtPlayer2.push_back(vtCard[iCard])

break

default:

vtPlayer3.push_back(vtCard[iCard])

break

}

if( iCard != vtCard.size()-1 )

{

vtCard[iCard] = vtCard[vtCard.size()-1]

}

vtCard.pop_back()

}

}

/察皮灶/ 叫牌

int Bid(vector<st_Card_t>&vtCard, vector<st_Card_t>&vtPlayer1,

vector<st_Card_t>&vtPlayer2, vector<st_Card_t>&vtPlayer3)

{

srand( (unsigned)time( NULL ) )

int iBider = rand() % 3 // 叫牌者,也就是地主

vector<st_Card_t>* pPlayer = NULL

switch( iBider )

{

case 0:

pPlayer = &vtPlayer1

break

case 1:

pPlayer = &vtPlayer2

break

default:

pPlayer = &vtPlayer3

break

}

for( UINT i = 0i <vtCard.size()i++ )

{

pPlayer->push_back(vtCard[i])

}

return iBider

}

// 整牌(按红桃、黑桃、梅花、方块、小大王的花色顺序整理,同一花色再按从小到大的顺序整理)

void SortCard(vector<st_Card_t>&vtPlayer)

{

st_Card_t tmp

for( UINT i=0i<vtPlayer.size()-1i++ )

{

for( UINT j=i+1j<vtPlayer.size()j++ )

{

if( vtPlayer[i]._emCardClass <vtPlayer[j]._emCardClass )

{

continue

}

if( vtPlayer[i]._emCardClass == vtPlayer[j]._emCardClass &&

vtPlayer[i]._uCardIndex <vtPlayer[j]._uCardIndex )

{

continue

}

tmp = vtPlayer[i]

vtPlayer[i] = vtPlayer[j]

vtPlayer[j] = tmp

}

}

}

void PrintPlayerCard(const string&sPlayerName,

const vector<st_Card_t>&vtPlayer)

{

cout <<sPlayerName <<" cards:" <<endl

for( UINT i=0i<vtPlayer.size()i++ )

{

switch( vtPlayer[i]._emCardClass )

{

case _CC_hearts:

cout <<"红桃"

break

case _CC_Spade:

cout <<"黑桃"

break

case _CC_Clubs:

cout <<"梅花"

break

case _CC_Diamonds:

cout <<"方块"

break

default:

cout <<"King"

break

}

cout <<vtPlayer[i]._uCardIndex<<" "

}

cout <<endl <<endl

}

void main()

{

vector<st_Card_t>vtCard

vector<st_Card_t>vtPlayer1

vector<st_Card_t>vtPlayer2

vector<st_Card_t>vtPlayer3

InitCard(vtCard)

DealCard(vtCard, vtPlayer1, vtPlayer2, vtPlayer3)

int iBider = Bid(vtCard, vtPlayer1, vtPlayer2, vtPlayer3)

SortCard(vtPlayer1)

SortCard(vtPlayer2)

SortCard(vtPlayer3)

PrintPlayerCard("Player1", vtPlayer1)

PrintPlayerCard("Player2", vtPlayer2)

PrintPlayerCard("Player3", vtPlayer3)

cout <<"地主是Player"<<iBider+1 <<endl <<endl

}

这是以随咐旁机的形式发牌的。希望能帮到你。

int main(){int a[60] int b[60] int w = 0 int wi,wj,wii int i,j,index,x=0,m for(i=0i<54i++)a[i]=i+1 srand((unsigned)time(0)) for(i=0i<54){index=rand()%54 if(a[index]!=0){b[i]=a[index] //printf("%d ",b[i]) a[index]=0 ++i }}printf("\n说明:\n") printf("*******************\n") printf("**红桃 %c ",3) printf("**\n") printf("**方块 %c ",4) printf("**\n") printf("**梅花 %c ",5) printf("**\n") printf("**黑桃 %c ",6) printf("**\n") printf("**大王 A **\n**小王 a **\n") printf("*******************\n") printf("\n请输入打牌人数:薯简段\n") scanf("%d",&w) wi = 54/w wj = 54%w //printf("%d,%d",wi,wj) for (j = 0j <wj++){m = 0 printf("\n\n第%d个人的数誉牌\n",j+1) wj -- if (wj>=0)wii = wi + 1 elsewii = wi//红桃printf("红桃 %c ",3) printf(":") for(i = j*wiii<(j+1)*wiii++){if (b[i]<=13&&b[i]>0){m++ if (b[i]==11)printf("J ") else if (b[i]==12)printf("Q ") else if (b[i]==13)printf("K ") elseprintf("%d ",b[i]) }} //方块printf("\n方块 %c ",4) printf(":") for(i = j*wiii<(j+1)*wiii++){if (b[i]<=26&&b[i]>13){m++ b[i] = b[i]-13 if (b[i]==11)printf("J ") else if (b[i]==12)printf("Q ") else if (b[i]==13)printf("K ") elseprintf("%d ",b[i]) }} //梅花printf("\n梅花 %c ",5) printf(":") for(i = j*wiii<(j+1)*wiii++){ if (b[i]<=39&&b[i]>26){m++ b[i] = b[i]-26 if (b[i]==11)printf("J ") else if (b[i]==12)printf("Q ") else if (b[i]==13)printf("K ") elseprintf("%d ",b[i]) }}//黑桃printf("\n黑桃 %c ",6) printf(":") for(i = j*wiii<(j+1)*wiii++){if (b[i]<=52&&b[i]>39){m++ b[i] = b[i]-39 if (b[i]==11)printf("J ") else if (b[i]==12)printf("Q ") else if (b[i]==13)printf("K ") elseprintf("%d ",b[i]) }}//大小王printf("\n大小王 A or a :") for(i = j*wiii<=(j+1)*wiii++){if (b[i]==53){m++ printf("A ") }if (b[i]==54){m++ printf("a ") }}printf("\n总共:%d张牌!!!",m) } }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12253927.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存