C语言程序:把20个随机数存入一个数组,然后输出该数组中的最大值!!求解!!

--------------------Configuration: l - Win32 Debug--------------------
Linking...
ad.obj : error LNK2005: _fun already defined in l.obj
ad.obj : error LNK2005: _main already defined in l.obj
fg.obj : error LNK2005: _main already defined in l.obj
Debug/l.exe : fatal error LNK1169: one or more multiply defined symbols found
执行 link.exe 时出错.
l.exe - 1 error(s), 0 warning(s)
这是推荐答案连接时的情况,请问是哪里出现了问题??

第1个回答  2012-07-03
# include <stdio.h>
# include <time.h>
# include <stdlib.h>
int main(void)
{
int a[20],i,max;
srand((unsigned int) time(0));
max=a[0] = rand() % 100 + 1;
for (i= 1; i < 20; ++i)
{
a[i] = rand() % 100 + 1;
if(a[i]>max) max=a[i];
}
printf("max=%d\n",max);
return 0;
}本回答被网友采纳
第2个回答  2012-07-03
The Max is :89
Press any key to continue

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
main()
{
int i,a[20],amax;
srand((unsigned)time(NULL));
for (i=0;i<20;i++)
{
a[i]=rand()%99+1;
if (i==0 || a[i]>amax )
amax= a[i];
}
printf("The Max is :%d\n",amax);
}本回答被提问者采纳
相似回答