i am not getting desired output

this is part of my program, can anyone tell me what went wrong in it because of which i am getting unacceptable output:



srand(4);
cout<<"Centroids points initially randomly generated \n";
for(int t=0;t<no_of_cluster;t++)
{ cout<<"value of t is:"<<t<<"\n";
cout<<"centroid no :"<<t<<"\n";
for(int y=0;y<feature;y++)
{
centroid[t][y]=(rand()%10000)/10000.0000;
cout<<centroid[t][y]<<" ";
}
cout<<"\n";
}
cout<<centroid[0][0]<<" "<<centroid[0][1]<<" "<<centroid[0][2]<<" "<<centroid[0][3]<<"\n"<<centroid[1][0]<<" "<<centroid[1][1]<<" "<<centroid[1][2]<<" "<<centroid[1][3]<<"\n";




The output is:


Centroids points initially randomly generated
value of t is:0
centroid no :0
0.8301 0.4083 0.2274 0.9326
value of t is:1
centroid no :1
0.5363 0.0537 0.0025 0.2363
0.5363 0.0537 0.0025 0.2363
0.5363 0.0537 0.0025 0.2363


***********************************

where as in the second last line it should be 0.8301 0.4083 0.2274 0.9326 instead of 0.5363 0.0537 0.0025 0.2363



Hi,
because the rand() returen a result of random ,so you should insert sleep() before rand()
i didnt get what you are tring to say, can you explain a little more
Sorry I give you wrong answer.Can you put on more Code?
Topic archived. No new replies allowed.