| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 973 人关注过本帖
标题:这个程序哪里错了。如何变?
只看楼主 加入收藏
我是岳阳人
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2004-8-13
收藏
 问题点数:0 回复次数:2 
这个程序哪里错了。如何变?
#include "stdlib.h"

#include "stdio.h"

#define M 50

#define N 10

getdata (int *s)

{ int i;

for(i=0; i<M; i++) s=random(10);

}

stat(int *a,int *c)

{ int i;

for(i=0;i<N; i++) c=0;

for(i=0;i<M; i++) c[a]++;

}

outdata (int *c)

{int i;

for (i=0;i<N; i++) printf("%d : %d\n",i,c);

}

main()

{ int a[M],c[N];

getdata (a);

stat(a,c);

printf("Output the result: \n");

outdata(c);

}

出现了“rror C2065: 'random' : undeclared identifier“



4iBxndxm.jpg (19.34 KB)
图片附件: 游客没有浏览图片的权限,请 登录注册
天地一沙鸥
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2004-8-14
收藏
得分:0 

哦哦哦,~我也不清楚,希望有人能告诉我


鸟凄声以孤归, 兽索偶而不还。 悼当年之晚暮, 恨兹岁之欲殚。 思宵梦以从之, XXX而不安; 若凭舟之失棹, 譬缘崖而无攀。 /img/assets/200401/200401061015134010607.jpg" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://joke./img/assets/200401/200401061015134010607.jpg');}" onmousewheel="return imgzoom(this);" alt="" />
TARGET_MG42
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2004-8-7
收藏
得分:0 

程序可以运行!

但是有警告:

子函数前应该有返回类型;还有random返回的是int型,而s是整型指针,整型指针不能直接赋给整型数,除非强制类型转换!

不过,我估计你上面的问题在于编译器,可能没有stdlib.h 头文件,或者在stdlib.h头文件中没有定义random()函数!你试试 用另一个随机函数rand()%num!

  • 3
  • 1/1页
  • 1
快速回复:这个程序哪里错了。如何变?
数据加载中...
 
   



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

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