| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 597 人关注过本帖
标题:大家看一下,它报的错误很特别,我看不懂,请大家帮帮忙!!
只看楼主 加入收藏
renhu
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-11-27
收藏
 问题点数:0 回复次数:7 
大家看一下,它报的错误很特别,我看不懂,请大家帮帮忙!!

#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>

using namespace std;

void shuffle(int [][13]);
void deal(const int[][13],const char*[],const char *[],int [][2]);
void pairs(const int[][13],const int [][2],const char*[]);
void threeofkind(const int[][13],const int [][2],const char *[]);
void fourofkind(const int [][13],const int[][2],const char*[]);
void flushhand(const int[][13],const int [][2],const char*[]);
void straighthand(const int [][13],const int [][2],const char*[],const char*[]);

int mian()
{
const char *suit[]={"hearts","diamonds","clubs","spades"};
const char *face[]={"ace","deuce","three","four","five","six",
"seven","eight","nine","ten","jack","queen","king"};
int deck[4][13]={0};
int hand[5][2]={0};

srand(time(0));

shuffle(deck);

deal(deck,face,suit,hand);
pairs(deck,hand,face);
threeofkind(deck,hand,face);
fourofkind(deck,hand,face);
flushhand(deck,hand,suit);
straighthand(deck,hand,suit,face);

return 0;

}

void shuffle(int wdeck[][13])
{
int row;
int column;

for(int card=1;card<=52;card++){
do{
row=rand()%4;
column=rand()%13;
}while(wdeck[row][column]!=0);

wdeck[row][column]=card;

}

}

void deal(const int wdeck[][13],const char *wface[],
const char *wsuit[],int whand[][2])
{
int r=0;
cout<<"the hand is :\n";

for(int card=1;card<6;card++)
for(int row=0;row<=3;row++)
for(int column=0;column<=12;column++)
if(wdeck[row][column]==card){//这里是取已经洗好了的前5张牌
whand[r][0]=row;
whand[r][1]=column;
cout<<setw(5)<<wface[column]
<<" of"<<setw(8)<<left
<<wsuit[row]<<(card%2==0?'\n':'\t')
<<left;
r++;

}
cout<<'\n';

}

void pairs(const int wdeck[][13],const int whand[][2],const char *wface[])
{
int counter[13]={0};

for(int r=0;r<5;r++)
++counter[whand[r][1]];

cout<<'\n';

for(int p=0;p<13;p++)
if(counter[p]==2)
cout<<"the hand contains a pair of"<<wface[p]<<"'s.\n";

}

void threeofkind(const int wdeck[13],const int whand[][2],const char*wface[])
{
int counter[13]={0};

for(int r=0;r<5;r++)
++counter[whand[r][1]];

cout<<'\n';

for(int p=0;p<13;p++)
if(counter[p]==3)
cout<<"the hand contains three"<<wface[p]<<"'s.\n";

}

void fourofkind(const int wdeck[][13],const int whand[][2],const char*wface[])
{
int counter[13]={0};

for(int r=0;r<5;r++)
++counter[whand[r][1]];

cout<<'\n';

for(int p=0;p<13;p++)
if(counter[p]==4)
cout<<"the hand contains four"<<wface[p]<<"'s.\n";

}

void flushhand(const int wdeck[][13],const int whand[][2],const char*wsuit[])
{
int counter[13]={0};

for(int r=0;r<5;r++)
++counter[wsuit[r][0]];

cout<<'\n';

for(int p=0;p<13;p++)
if(counter[p]==5)
cout<<"the hand contains a flush of"<<wsuit[p]<<"'s.\n";

}


void strainghthand(const int wdeck[][13],const int whand[][2],const char *wsuit[],
const char *wface[])
{
int s[5]={0};
int temp;

for(int r=0;r<5;r++)
s[r]=whand[r][1];

for(int pass=0;pass<4;pass++)
for(int comp=pass+1;comp<5;comp++)
if(s[pass]>s[comp]){
temp=s[pass];
s[pass]=s[comp];
s[comp]=temp;
}

if(s[4]-1==s[3] && s[3]-1==s[2] && s[2]-1==s[1] && s[1]-1==s[0]){

cout<<"the hand contains a strainght consisting of\n";

for(int j=0;j<5;j++)
cout<<wface[whand[j][1]]<<" of"<<wsuit[whand[j][0]]
<<'\n';
}

}

2005-11-30 23:14
honey0607
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-9-15
收藏
得分:0 
你要做什么?

2005-12-01 10:50
史前大暴龙
Rank: 1
等 级:新手上路
帖 子:375
专家分:0
注 册:2005-11-22
收藏
得分:0 
我是新手,帮不了你什么,但是不知你的程序是用来做什么的,也没怎么看,那个

void shuffle(int [][13]);
void deal(const int[][13],const char*[],const char *[],int [][2]);
void pairs(const int[][13],const int [][2],const char*[]);
void threeofkind(const int[][13],const int [][2],const char *[]);
void fourofkind(const int [][13],const int[][2],const char*[]);
void flushhand(const int[][13],const int [][2],const char*[]);
void straighthand(const int [][13],const int [][2],const char*[],const char*[]);

定义的有没有错啊,可以这样定义的吗???

我不是最好,但我可以更好,大家一起加油了
2005-12-01 11:32
renhu
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-11-27
收藏
得分:0 

这个程序的功能是先洗牌,再发5张牌,并且对这5张牌进行判断,看是否有对子,或者3个的,或者炸子,或者同花,或者顺子。

2005-12-01 12:33
虫虫飞ya飞
Rank: 1
等 级:新手上路
帖 子:122
专家分:0
注 册:2005-11-28
收藏
得分:0 
除了看到一个拼写错误外 int main()....其他还看不懂呵呵

2005-12-01 16:24
Jewgle
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2005-10-12
收藏
得分:0 
又没说明,又没注释,晕晕的...
2005-12-01 18:30
lll1231230
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2005-9-6
收藏
得分:0 

我在TCFORWIN 5.0上运行
需要在库函数中加.h
srand函数 是 stdlib.h中的
还有个拼写错误
下面的不懂

using namespace std;
还有个错误没看懂

总体说来不会

2005-12-02 13:40
renhu
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-11-27
收藏
得分:0 

谢谢你 虫虫飞ya飞 的发现,但是我改了之后还是有3个错误,我把错误复制下来了 ,请大家指教一下!!
谢谢了,这程序我真的搞了好几天了。。
谢谢了

-------------------Configuration: practice - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol "void __cdecl straighthand(int const (* const)[13],int const (* const)[2],char const * * const,char const * * const)" (?straighthand@@YAXQAY0N@$$CBHQAY01$$CBHQAPBD2@Z)
main.obj : error LNK2001: unresolved external symbol "void __cdecl threeofkind(int const (* const)[13],int const (* const)[2],char const * * const)" (?threeofkind@@YAXQAY0N@$$CBHQAY01$$CBHQAPBD@Z)
Debug/practice.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

practice.exe - 3 error(s), 0 warning(s)

2005-12-02 21:28
快速回复:大家看一下,它报的错误很特别,我看不懂,请大家帮帮忙!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016297 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved