Thursday, October 4, 2007

Assignment 1 code

#include
#include
#include

using namespace std;

int main()
{
srandom(time(0));

int p[1000]; //people array
int c,i; //people
int left=1000; //people left
int rand;
int rand2=0;


for(c=0;c<1000;c++)//populate room with 2000 people
{
p[c];
}

while(left>0)
{
rand=random()%1000;
if(rand!=0)
{
p[rand]=0;
left--;
rand2++;
cout << rand << " Just left room, there is " << left << " left and moved " <<
rand2 <<
endl;
}
}



return 0;
}

No comments: