Thread: help with people counting program..

  1. #1
    Registered User
    Join Date
    Jun 2006

    help with people counting program..

    I'm trying to to a simple people counting program.
    The scenerio is that is a passageway to a room and i wanted to count how many people going in and how many people going out.

    Thank you very much if u can help me..

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    Well, there are some things that will matter when you write this algorithm:
    - how many people will be in the hallway at once?
    - who walks the fastest/slowest?
    - how long does it take for these people to go from one room to another?
    - how many people can be in a room at once?
    Answer those questions and work out the algorithm from there.

  3. #3
    Registered User
    Join Date
    May 2005

    A Little Help

    Hello, I saw your post and prepared this code for you , it's not complete yet, but it is up to you to finish the simulation of the counting:

    #include <iostream>
    #include <ctime>
    #include <cstdlib>
    #define _IN    200         //STATUS GOING IN
    #define _OUT   201        //STATUS GOING OUT
    #define _STAY  300        //STATUS ON THE ROOM
    using namespace std;
    const int iPeople = 100;        //# of People
    const int iSTAYallowed  = 75;       //Max allowed to STAY
    void Start();			//Initialize Random Speeds
    void Simulation(void);        //Simulation
    void Update();		         //Update to the Display
    struct Person			//The person(s)
    	int speed;
    	int status;
    struct _Display			//Update Status
    	int iPeoIn;
    	int iPeoOut;
    	int iPeoStay;
    int main()
    	cout<<"\nPress [Enter] to start Simulation\n"<<endl;
    	return 0; //or exit(0);
    void Simulation(void)
        CODE HERE:
    void inline Update()
    	int in =0,
    	for(int x=0; x<=iPeople; x++)
    		if(People[x].status == _OUT)
    		if(People[x].status == _IN)
    		if(People[x].status == _STAY)
    		Display.iPeoIn = in;
    		Display.iPeoOut = out;
    		Display.iPeoStay = stay;
    void Start()
    	srand( (unsigned) time(NULL) );         //Random Seed
    	for(int x=0; x<=iPeople; x++)          //Assinging Speeds and Status
    		People[x].speed = rand()%5000;
    		People[x].status = _OUT;
    I already declared almost everything that you need, hope it helps
    Be easy on me...only 14

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-02-2007, 05:40 AM
  2. Help counting people in my array.
    By gator6688 in forum C++ Programming
    Replies: 4
    Last Post: 10-17-2007, 04:35 PM
  3. program error :counting length of string
    By bigjoke in forum C Programming
    Replies: 19
    Last Post: 12-27-2005, 03:21 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Looking for people with IIS to test my program
    By Sang-drax in forum A Brief History of
    Replies: 3
    Last Post: 04-22-2003, 03:16 PM