大侠帮我看看这个c语言程序错在那里
运行一直提示错误,不知道是什么原因....请大家帮我看看,谢谢.程序如下:#include"stdio.h"#defineN10staticunsignedlongk=-...
运行一直提示错误,不知道是什么原因....请大家帮我看看,谢谢.程序如下:
#include "stdio.h"
#define N 10
static unsigned long k=-1
void long unsigned startnum(unsigned int seed)
{
k=seed;
}
unsigned randnum(long n)
{
k=((k*159+23)%n)+1);
return k;
}
main()
{
register unsigned int i;
long n=0;
while(!(n>0&&(k>0&&k<=65536)))
{
printf("\n Input the seed and the max random[1-65535]:\n");
scanf("%ld%ld",&k,&n);
if(n<=0)
printf("\n wrong seed!");
if(k<=0||k>65536)
printf("\n wrong man random");
}
startnum(n);
for(i=0;i<N;i++)
printf("%6u",randnum(n));
return;
} 展开
#include "stdio.h"
#define N 10
static unsigned long k=-1
void long unsigned startnum(unsigned int seed)
{
k=seed;
}
unsigned randnum(long n)
{
k=((k*159+23)%n)+1);
return k;
}
main()
{
register unsigned int i;
long n=0;
while(!(n>0&&(k>0&&k<=65536)))
{
printf("\n Input the seed and the max random[1-65535]:\n");
scanf("%ld%ld",&k,&n);
if(n<=0)
printf("\n wrong seed!");
if(k<=0||k>65536)
printf("\n wrong man random");
}
startnum(n);
for(i=0;i<N;i++)
printf("%6u",randnum(n));
return;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询