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;
}

Tuesday, October 2, 2007

Assignment 1: Stimulating line que

Write code to stimulate following:
There are 1,000 people in a room, each person has unique number from 1 to 1000. When number is drawn person with that number will move out of room. Stop when there is no more people in room.

Do:
Write a code to stimulate this process and output the sequence of people being moved out (print their numbers).
Code needs to be efficient.
No memory leaks, only generate 1000 people to move 1000 people.

That's problem, I will post code tommorow.

C plus plus newbie

My name is Stephan I just started learning C plus plus and thought it would be good for me to blog about it. By blogging about it I can chart my progress and share my code. For one I will be more involved, right now I have been in class for over month and haven't opened book much. This becomes problem. My solution is to blog about it.

Three objectives I want to accomplish with my endeavour:
  1. Update blog three times a week.
  2. Post all my assignments code.
  3. Write a mini tutorial once a week.