标题:C++ 中有关 srand 我这个为什么在 Dev-c++ 里面不能运行? VC 就能运行?
取消只看楼主
yu497272290
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2013-11-2
结帖率:42.86%
 问题点数:0 回复次数:2 
C++ 中有关 srand 我这个为什么在 Dev-c++ 里面不能运行? VC 就能运行?
程序代码:
#include<iostream>
#include<time.h>
using namespace std;//使用命名空间 std.

int main()
{

 srand(time(NULL));//将时钟数作为随机数种子
 

 int price,guess;

 price = rand() % 1000 + 1;//取余,获得1~1000的随机数
 

 cout << "please input the price:" << endl;

 

 do{

 

 cin >> guess;//记录玩家所输入数值
 if(guess > price)
    cout << "The price is lower than your guess,please input the price again:" << endl;

 if(guess < price)
    cout << "The price is higher than your guess,please input the price again:" << endl;//给予玩家比较大小的提示
 }

 while (guess != price);//循环结构
 

 cout << "The price you give is right.It cost " << price << "." <<endl;//获得正确答案
 system("pause");

 return 0;

 
}
搜索更多相关主题的帖子: price guess 
2014-09-03 23:04
yu497272290
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2013-11-2
得分:0 
?有人在吗?问一下
2014-09-03 23:09
yu497272290
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2013-11-2
得分:0 
加上
#include <stdlib.h>

我前几天和你一样
2014-09-06 15:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-435660-1-1.html




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

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