输出用自己的随机种子只有 一个随机数,错在哪里?

z1202009 2011-05-15 11:10:36
#include<iostream>
#include<iomanip>
#include<ctime>
#include<string>
using namespace std;
int main()
{
cout<<"\n random number generator demo";
int seed,number,i;
string answer;
cout<<"\n\n first ,here are 8 random numbers."
<<"\n we used the time function for seed value.\n";
srand((unsigned)time(NULL));
for(i=0;i<8;++i)
{
number=rand();
cout<<setw(8)<<number;
}
cout<<"choose the value";
do
{
cout<<"\n\n please enter a seed value for rand()";
cin>>seed ;
cin.ignore();
srand(seed);
cout<<"eight numbers with seed "<<seed<<endl;
for(i=0;i<8;++i);

{
number=rand();
cout<<setw(8)<<number;
}
cout<<"\n do another ? yes/no";
getline(cin,answer);
}
while (answer=="yes");
return 0;
}
...全文
64 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
z1202009 2011-05-16
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 pgplay 的回复:]
for(i=0;i<8;++i);<-多了一个分号
[/Quote] 谢谢。
lirg8405 2011-05-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 pgplay 的回复:]
for(i=0;i<8;++i);<-多了一个分号
[/Quote]
神眼
耍宝王 2011-05-15
  • 打赏
  • 举报
回复
for(i=0;i<8;++i);<-多了一个分号

64,639

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧