rat race program.. i nid a syntax... ASAP...

this is my examination as a com sci student.. to make a rat race program which ask for the number of rats then randomly races to the finish line.... my prof said to use randomize()... so that the rats will randomly race to the finish line... can anybody giv me a syntax of this program? i really nid it badly... rats are represented as ">"...

ask for number of rats,
displays rats,
>
> /*depending on the number of rats inputed*/
>
>
>
then rats randomly races to the finish line...

nid the syntax within 10 hours... plz do help me... plz!!!
thnx so much!

Comments

  • : this is my examination as a com sci student.. to make a rat race program which ask for the number of rats then randomly races to the finish line.... my prof said to use randomize()... so that the rats will randomly race to the finish line... can anybody giv me a syntax of this program? i really nid it badly... rats are represented as ">"...
    :
    : ask for number of rats,
    : displays rats,
    : >
    : > /*depending on the number of rats inputed*/
    : >
    : >
    : >
    : then rats randomly races to the finish line...
    :
    : nid the syntax within 10 hours... plz do help me... plz!!!
    : thnx so much!
    :


    Maybe if you show what you have done, and ask specific questions, people will be willing to help you. If you are completely stuck and don't know where to start, take that as a sign that you are not ready to move on to the next class.
  • : : this is my examination as a com sci student.. to make a rat race program which ask for the number of rats then randomly races to the finish line.... my prof said to use randomize()... so that the rats will randomly race to the finish line... can anybody giv me a syntax of this program? i really nid it badly... rats are represented as ">"...
    : :
    : : ask for number of rats,
    : : displays rats,
    : : >
    : : > /*depending on the number of rats inputed*/
    : : >
    : : >
    : : >
    : : then rats randomly races to the finish line...
    : :
    : : nid the syntax within 10 hours... plz do help me... plz!!!
    : : thnx so much!
    : :
    :
    :
    : Maybe if you show what you have done, and ask specific questions, people will be willing to help you. If you are completely stuck and don't know where to start, take that as a sign that you are not ready to move on to the next class.
    :
    Clearly correct knowledge of the English language is not stressed at your school. Next time try to give us somethimg more grammatically correct. And I don't think that the correct understanding of computer science terms was stressed very much either, you don't want the syntax, that's the form of the code (e.g. semicolon at the end of a line of code, backslashes for comments, etc), you want the code.
  • : this is my examination as a com sci student.. to make a rat race program which ask for the number of rats then randomly races to the finish line.... my prof said to use randomize()... so that the rats will randomly race to the finish line... can anybody giv me a syntax of this program? i really nid it badly... rats are represented as ">"...
    :
    : ask for number of rats,
    : displays rats,
    : >
    : > /*depending on the number of rats inputed*/
    : >
    : >
    : >
    : then rats randomly races to the finish line...
    :
    : nid the syntax within 10 hours... plz do help me... plz!!!
    : thnx so much!
    :

    I did a little pratice test.
    I made a buggy version of this game.
    It works for me on Dev C++.
    Maybe you can modify this code. ;)
    Here is the source (code is quickly written,not formmated,not commented :( ):
    [code]
    #include
    #include
    #include

    using namespace std;

    //Globals:
    int num_rats=0;
    int *positions;

    //Fucntions:
    void render_game(int);
    void clear_positions();
    void draw_finish(int);

    const int finish_line=75;

    int main(int argc, char *argv[])
    {

    cout<<"Welcome to rat race!"<<endl;
    cout<<"Please enter the number of rats:";
    cin>>num_rats;

    if(num_rats>0){
    positions=new int[num_rats];
    }
    clear_positions();

    render_game(num_rats);


    delete[] positions;
    system("PAUSE");
    return 0;
    }

    void render_game(int num_rats){
    int n=0;
    int i=0;

    srand(GetTickCount());
    int moved=0;

    bool break_it=false;

    while(true){
    system("cls");
    for(n=1;n<=num_rats;n++){

    if(!break_it){
    moved=rand() % 2;
    positions[n-1]+=moved;
    }
    if (positions[n-1]>=finish_line){
    break_it=true;


    }

    for(i=1;i";
    draw_finish(i);
    }

    if(break_it) return;
    Sleep(30);
    }

    }

    void clear_positions(){
    int n=0;
    for (n=0;n0){
    cout<<"|"<<endl;
    }else{
    cout<<endl;
    }
    }
    [/code]
  • : : this is my examination as a com sci student.. to make a rat race program which ask for the number of rats then randomly races to the finish line.... my prof said to use randomize()... so that the rats will randomly race to the finish line... can anybody giv me a syntax of this program? i really nid it badly... rats are represented as ">"...
    : :
    : : ask for number of rats,
    : : displays rats,
    : : >
    : : > /*depending on the number of rats inputed*/
    : : >
    : : >
    : : >
    : : then rats randomly races to the finish line...
    : :
    : : nid the syntax within 10 hours... plz do help me... plz!!!
    : : thnx so much!
    : :
    :
    : I did a little pratice test.
    : I made a buggy version of this game.
    : It works for me on Dev C++.
    : Maybe you can modify this code. ;)
    : Here is the source (code is quickly written,not formmated,not commented :( ):
    : [code]
    : #include
    : #include
    : #include
    :
    : using namespace std;
    :
    : //Globals:
    : int num_rats=0;
    : int *positions;
    :
    : //Fucntions:
    : void render_game(int);
    : void clear_positions();
    : void draw_finish(int);
    :
    : const int finish_line=75;
    :
    : int main(int argc, char *argv[])
    : {
    :
    : cout<<"Welcome to rat race!"<<endl;
    : cout<<"Please enter the number of rats:";
    : cin>>num_rats;
    :
    : if(num_rats>0){
    : positions=new int[num_rats];
    : }
    : clear_positions();
    :
    : render_game(num_rats);
    :
    :
    : delete[] positions;
    : system("PAUSE");
    : return 0;
    : }
    :
    : void render_game(int num_rats){
    : int n=0;
    : int i=0;
    :
    : srand(GetTickCount());
    : int moved=0;
    :
    : bool break_it=false;
    :
    : while(true){
    : system("cls");
    : for(n=1;n<=num_rats;n++){
    :
    : if(!break_it){
    : moved=rand() % 2;
    : positions[n-1]+=moved;
    : }
    : if (positions[n-1]>=finish_line){
    : break_it=true;
    :
    :
    : }
    :
    : for(i=1;i";
    : draw_finish(i);
    : }
    :
    : if(break_it) return;
    : Sleep(30);
    : }
    :
    : }
    :
    : void clear_positions(){
    : int n=0;
    : for (n=0;n0){
    : cout<<"|"<<endl;
    : }else{
    : cout<<endl;
    : }
    : }
    : [/code]
    :
    hey bro, thnx so much for the syntax.. its a big help!:) i'll try it.. thnx again..:)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories