| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 193 人关注过本帖
标题:程序中用到了随机函数,头文件加了#include 编译时还是说random没定义
收藏  订阅  推荐  打印 
SUN21
Rank: 1
等级:新手上路
帖子:3
积分:130
注册:2007-9-25
程序中用到了随机函数,头文件加了#include 编译时还是说random没定义

程序中用到了随机函数,头文件加了#include <stdlib.h> 编译时还是说 random,randomize没定义
不知怎么回事,程序如下:


#include "stdafx.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>

void myplus() ; //产生加法题
void myminus() ; //产生减法题


void myplus() {
int x ;
int y ;
int answer ;
randomize() ; //为随机函数提供不同的种子
x = random(100) ; //产生随机数
y = random(100) ;
printf("%d + %d = ?" , x,y) ;
scanf("%d" , &answer) ;
if ( answer == x+y )
printf("Great! You are clever!") ;
else
printf("You are wrong!") ;
getch() ; //等待输入,起暂停运行的作用
}

void myminus() {
int x ;
int y ;
int answer ;
randomize() ; //为随机函数提供不同的种子
x = random(100) ;
y = random(100) ;
printf("%d - %d = ?" , x,y) ;
scanf("%d" , &answer) ;
if ( answer == x-y )
printf("Great! You are clever!") ;
else
printf("You are wrong!") ;
getch() ; //等待输入,起暂停运行的作用
}

int main(int argc, char* argv[])
{
myplus() ;
myplus() ;
myminus() ;
myminus() ;
return 0 ;
}

搜索更多相关主题的帖子: 头文件  include  程序中  random  随机函数  
2007-10-10 14:26
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.074372 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved