大侠们,为什么相同的数列输出结果不一样?for里面的随机数列,但是for外面的却变成了长数列?
时间:2008-06-11 08:24:27
来源:论坛整理 作者: 编辑:chinaitzhe
#include <iostream.h>
#include <time.h>
#include <fstream.h>
#include <math.h>
const int n=500;
void main ()
{
ofstream pp("pp.txt",ios::out);
double dr=1.0,x[n]={0.0},y[n]={0.0},z[n]={0.0};
double r2[n]={0.0},a[n]={0.0},b[n]={0.0};
r2[1]=pow(x[0],2) pow(y[0],2) pow(z[0],2);
srand((unsigned)time(NULL));
for (int i=0;i <n;i )
{
a[i]=rand()/100.0;
srand(a[i]);
b[i]=rand()/30.0;
cout < <a[i] < <'\t' < <b[i] < <endl;
}
for (int m=0;m <n;m )
cout < <a[i] < <'\t' < <b[i] < <endl;
}
网友回复:for (int m=0;m <n;m )
cout < <a[i] < <'\t' < <b[i] < <endl;
不明白你在说什么 这里i有没变 难道不是常数
网友回复:汗了 呵呵~~~~~~~~~~~~谢谢啊 居然没注重到
关键字:大侠,相同,数列,输出,结果,
上一篇: Navigate2!郁闷了!
下一篇:下面没有链接了











文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面