主题:有管VC++程序的一些错误!!求高手帮忙
#include <stdlib.h>
int i;
int vgks,gks;
int vseat1,vseat2,vseat3;
int waiting,all;
int lfs;
int gk_waited,lfs_waited;
int fusj(a)
int a;
{
if(a>=0 && a<5) return 10;
else if (a>=5 && a<8) return 20;
else return 25;
}
main()
{
int seat1,seat2,seat3;
lfs=3;
seat1=seat2=seat3=0;
srand((unsigned)time(NULL));
printf("\nsk sjs gks vs1 vs2 vs3 #1 #2 #3 gkd dsj lfs sj\n");
for(i=1;i<145;i++)
{
vgks=random(9);
if(vgks>=0&&vgks<3)
gks=0;
else if (vgks>=3 && vgks<6)
gks=1;
else
gks=2;
all=waiting+gks;
if (all>0 )
{ if (seat1==0)
{vseat1=random(10);
seat1=fusj(vseat1);
all=all-1;
lfs=lfs-1;
}
}
if (all>0)
{if (seat2==0)
{vseat2=random(10);
seat2=fusj(vseat2);
all=all-1;
lfs=lfs-1;
}
}
if (all>0 )
{if (seat3==0)
{vseat3=random(10);
seat3=fusj(vseat3);
all=all-1;
lfs=lfs-1;
}
}
gk_waited=all*5;
lfs_waited=lfs*5;
waiting=all;
printf("\n%d %d %d %d %d %d %d %d %d %d %d %d %d",i,vgks,gks,vseat1,vseat2,vseat3,seat1,seat2,seat3,waiting,gk_waited,lfs,lfs_waited);
if (seat1 != 0)
{seat1=seat1-5;
if (seat1==0)
lfs=lfs+1;
}
if (seat2 != 0)
{seat2=seat2-5;
if (seat2==0)
lfs=lfs+1;
}
if (seat3 != 0)
{seat3=seat3-5;
if (seat3==0)
lfs=lfs+1;
}
getch();
}
getch();
}
-----------------------------
不知上面的程序错在了哪里,只是报出error LNK2001: unresolved external symbol _random
Debug/11.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
int i;
int vgks,gks;
int vseat1,vseat2,vseat3;
int waiting,all;
int lfs;
int gk_waited,lfs_waited;
int fusj(a)
int a;
{
if(a>=0 && a<5) return 10;
else if (a>=5 && a<8) return 20;
else return 25;
}
main()
{
int seat1,seat2,seat3;
lfs=3;
seat1=seat2=seat3=0;
srand((unsigned)time(NULL));
printf("\nsk sjs gks vs1 vs2 vs3 #1 #2 #3 gkd dsj lfs sj\n");
for(i=1;i<145;i++)
{
vgks=random(9);
if(vgks>=0&&vgks<3)
gks=0;
else if (vgks>=3 && vgks<6)
gks=1;
else
gks=2;
all=waiting+gks;
if (all>0 )
{ if (seat1==0)
{vseat1=random(10);
seat1=fusj(vseat1);
all=all-1;
lfs=lfs-1;
}
}
if (all>0)
{if (seat2==0)
{vseat2=random(10);
seat2=fusj(vseat2);
all=all-1;
lfs=lfs-1;
}
}
if (all>0 )
{if (seat3==0)
{vseat3=random(10);
seat3=fusj(vseat3);
all=all-1;
lfs=lfs-1;
}
}
gk_waited=all*5;
lfs_waited=lfs*5;
waiting=all;
printf("\n%d %d %d %d %d %d %d %d %d %d %d %d %d",i,vgks,gks,vseat1,vseat2,vseat3,seat1,seat2,seat3,waiting,gk_waited,lfs,lfs_waited);
if (seat1 != 0)
{seat1=seat1-5;
if (seat1==0)
lfs=lfs+1;
}
if (seat2 != 0)
{seat2=seat2-5;
if (seat2==0)
lfs=lfs+1;
}
if (seat3 != 0)
{seat3=seat3-5;
if (seat3==0)
lfs=lfs+1;
}
getch();
}
getch();
}
-----------------------------
不知上面的程序错在了哪里,只是报出error LNK2001: unresolved external symbol _random
Debug/11.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.