主题:求助,c扑克牌发牌程序不知问题出在哪
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main()
{
int a[54]={54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54};
int i,j,sign,k=0;
int change(int);
int order(int);
srand(time(0));
for(i=0;i<54;i++)
{
do
{
sign=0;
a[i]=rand()%54;
for(j=0;j<i;j++)
if(a[j]==a[i])
{
sign=1;
}
}
while(sign==1);
}
printf("\n");
for(i=0;i<54;i++)
{
change(a[i]);
printf("\t\t");
k++;
if(k%4==0)
printf("\n");
}
printf("\n");
for(i=0;i<54;i++)
order(a[i]);
printf("\n");
for(i=0;i<54;i++)
{
change(a[i]);
printf("\t\t");
k++;
if(k%4==0)
printf("\n");
}
printf("\n");
}
int order(int *a)
{
int i,j,k,p,t,s;
for(k=0;k<4;k++)
{
for(i=k;i<54;i=i+4)
{
p=a[i]%13;
s=a[i];
for(j=i+4;j<54;j=j+4)
{
if(a[j]%13<p)
s=a[j];
}
if(s!=a[i])
{
t=a[i];
a[i]=s;
s=t;
}
}
}
}
int change(int i)
{
if(i>=0&&i<=12)
{
switch(i)
{
case 0: printf("红桃A");break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:printf("红桃%d",i+1);break;
case 10:printf("红桃J");break;
case 11:printf("红桃Q");break;
case 12:printf("红桃K");break;
default:printf("");
}
}
if(i>=13&&i<=25)
{
switch(i)
{
case 13:printf("黑桃A");break;
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:printf("黑桃%d",i-13+1);break;
case 23:printf("黑桃J");break;
case 24:printf("黑桃Q");break;
case 25:printf("黑桃K");break;
default:printf("");
}
}
if(i>=26&&i<=38)
{
switch(i)
{
case 26:printf("方块A");break;
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:printf("方块%d",i-26+1);break;
case 36:printf("方块J");break;
case 37:printf("方块Q");break;
case 38:printf("方块K");break;
default:printf("");
}
}
if(i>=39&&i<=51)
{
switch(i)
{
case 39:printf("梅花A");break;
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:printf("梅花%d",i-39+1);break;
case 49:printf("梅花J");break;
case 50:printf("梅花Q");break;
case 51:printf("梅花K");break;
default:printf("");
}
}
if(i==52)
printf("小王");
if(i==53)
printf("大王");
return 1;
}
这是我的程序,但是运行的时候有问题,问题出在order个函数身上,我这个函数是用来把图片中的每列排序,但是好像是函数定义的问题,希望高手指教.先谢过
在VC上面运行的时候提示是这样的
--------------------Configuration: Poker - Win32 Debug--------------------
Linking...
Poker.obj : error LNK2001: unresolved external symbol "int __cdecl order(int)" (?order@@YAHH@Z)
Debug/Poker.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Poker.exe - 2 error(s), 0 warning(s)
貌似出了点问题,图片没了,没有order函数的时候出来的结果是4列的,就是排序不会了…
#include <stdlib.h>
#include <time.h>
void main()
{
int a[54]={54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54};
int i,j,sign,k=0;
int change(int);
int order(int);
srand(time(0));
for(i=0;i<54;i++)
{
do
{
sign=0;
a[i]=rand()%54;
for(j=0;j<i;j++)
if(a[j]==a[i])
{
sign=1;
}
}
while(sign==1);
}
printf("\n");
for(i=0;i<54;i++)
{
change(a[i]);
printf("\t\t");
k++;
if(k%4==0)
printf("\n");
}
printf("\n");
for(i=0;i<54;i++)
order(a[i]);
printf("\n");
for(i=0;i<54;i++)
{
change(a[i]);
printf("\t\t");
k++;
if(k%4==0)
printf("\n");
}
printf("\n");
}
int order(int *a)
{
int i,j,k,p,t,s;
for(k=0;k<4;k++)
{
for(i=k;i<54;i=i+4)
{
p=a[i]%13;
s=a[i];
for(j=i+4;j<54;j=j+4)
{
if(a[j]%13<p)
s=a[j];
}
if(s!=a[i])
{
t=a[i];
a[i]=s;
s=t;
}
}
}
}
int change(int i)
{
if(i>=0&&i<=12)
{
switch(i)
{
case 0: printf("红桃A");break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:printf("红桃%d",i+1);break;
case 10:printf("红桃J");break;
case 11:printf("红桃Q");break;
case 12:printf("红桃K");break;
default:printf("");
}
}
if(i>=13&&i<=25)
{
switch(i)
{
case 13:printf("黑桃A");break;
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:printf("黑桃%d",i-13+1);break;
case 23:printf("黑桃J");break;
case 24:printf("黑桃Q");break;
case 25:printf("黑桃K");break;
default:printf("");
}
}
if(i>=26&&i<=38)
{
switch(i)
{
case 26:printf("方块A");break;
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
case 34:
case 35:printf("方块%d",i-26+1);break;
case 36:printf("方块J");break;
case 37:printf("方块Q");break;
case 38:printf("方块K");break;
default:printf("");
}
}
if(i>=39&&i<=51)
{
switch(i)
{
case 39:printf("梅花A");break;
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:printf("梅花%d",i-39+1);break;
case 49:printf("梅花J");break;
case 50:printf("梅花Q");break;
case 51:printf("梅花K");break;
default:printf("");
}
}
if(i==52)
printf("小王");
if(i==53)
printf("大王");
return 1;
}
这是我的程序,但是运行的时候有问题,问题出在order个函数身上,我这个函数是用来把图片中的每列排序,但是好像是函数定义的问题,希望高手指教.先谢过
在VC上面运行的时候提示是这样的
--------------------Configuration: Poker - Win32 Debug--------------------
Linking...
Poker.obj : error LNK2001: unresolved external symbol "int __cdecl order(int)" (?order@@YAHH@Z)
Debug/Poker.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Poker.exe - 2 error(s), 0 warning(s)
貌似出了点问题,图片没了,没有order函数的时候出来的结果是4列的,就是排序不会了…