//file: sticfigure.cpp
//Draw a stick figure (main function only 0

# include <iostream>
using namespace std;

// Functions used ... 
void drawCircle ();
void drawTriangle();
void drawIntersect();
void drawBase();

int main()
{
    drawCircle();
    drawTriangle();
    drawIntersect();

    
    return 0;
}

//Draws a circle
void drawCircle()
{ 
     cout<< "   *  " <<endl;
     cout<< " *   * " <<endl;
     cout << "  * * "<< endl;
     cin.get();
     }
     //end drawCircle
     
     // Draws a triangle
     void drawTriangle()
     {
          drawIntersect();
          drawBase();
          } // end drawTriangle
          
          // Draws intersecting lines
          void drawIntersect()
          {
           cout << " / \ \ "<< endl;
           cout << " / \ \ " << endl;
           cout << " /  \ \ " << endl;
           cin.get();
           } //end drawIntersect
           
           //Draw a horizontal Lien
           void drawBase()
           {
                cout << " _ _ _ _  _ _ _ " << endl;
                } //end drawBase

I don't know why the program does not run base on the order I set up
it draw the base before the intersect..

Recommended Answers

All 11 Replies

I don't know why the program does not run base on the order I set up
it draw the base before the intersect..

Nope, it does exactly what you program to do.
Delete all the cin.get() inside the functions, and call them if you want after it draws each figure inside of main. Then take a look again.

if we don't use cin.get . How can we keep the program so that we can see the result, it will run really quick. thanks for answering. I don't know what are your ideas
and when I draw the intersect ,the program only draw one side.

if we don't use cin.get . How can we keep the program so that we can see the result, it will run really quick. thanks for answering.

Just put one cin.get(); in your program, before the return 0; in main()

>if we don't use cin.get . How can we keep the program so that we can see the result, it will run really quick.
That's not what I said. But since you ask me there's always the ability of running it at the console. If you must you only need one cin.get() before the program finishes at main.

>and when I draw the intersect ,the program only draw one side.
That's another problem. Let me guess. It only shows the "/" side?
Give you a hint: \t \n \a what do they have in common?

>if we don't use cin.get . How can we keep the program so that we can see the result, it will run really quick.
That's not what I said. But since you ask me there's always the ability of running it at the console. If you must you only need one cin.get() before the program finishes at main.

>and when I draw the intersect ,the program only draw one side.
That's another problem. Let me guess. It only shows the "/" side?
Give you a hint: \t \n \a what do they have in common?

this is the sample run,
*
* *
* *
/
/
/
_ _ _ _ _ _ _
/
/
/


which supposed to be different right,
that why I need your help

And what you want is something like theses, right?

**
  *    *
  *    *
    **

    / \
   /   \
  /     \
  _ _ _ _

    / \
   /   \
  /     \

And what you want is something like theses, right?

**
  *    *
  *    *
    **

    / \
   /   \
  /     \
  _ _ _ _

    / \
   /   \
  /     \

please help me how to do this?, sorry if it kind of silly, cause I have just studied C++ for 10 days...

>please help me how to do this?, sorry if it kind of silly, cause I have just studied C++ for 10 days...
I am trying but I can not read your mind, and all that I have is your code which it doesn't show clearly what you are trying to do. I am guessing.

If that's what you want (referring to my previous diagram), the stumbling block is the spacing between characters, which are not the proper ratio, and even makes the "\" disappear because it is interpreted as a scape character.

.
.
.
int main()
{
    drawCircle();
    drawTriangle();
    drawIntersect();
    cin.get();


    return 0;
}

//Draws a circle
void drawCircle()
{ 
    cout<< "    **  " <<endl;
    cout<< "  *    * " <<endl;
    cout<< "  *    * " <<endl;
    cout<< "    **  "<< endl;

}
//end drawCircle

// Draws a triangle
void drawTriangle()
{
    drawIntersect();
    drawBase();
} // end drawTriangle

// Draws intersecting lines
void drawIntersect()
{
    cout << "    / \\ "<< endl;
    cout << "   /   \\ " << endl;
    cout << "  /     \\ " << endl;
} //end drawIntersect

//Draw a horizontal Lien
void drawBase()
{
    cout << "  _ _ _ _ " << endl;
} //end drawBase

thank you very much, and one more thing I wanna ask is why the program draw the intersect two times, I saw we have only one time.

You are calling drawIntersect() two times:
First inside function drawTriangle(), and second time inside main()

please help me how to do this?, sorry if it kind of silly, cause I have just studied C++ for 10 days...

Ten days...? You should be an expert of the language by now. Specially, when there are incredible books for mastering programming in just twenty-four hours.
Just kidding. ;)

thank you very much [...]

You are welcome.
As an added bonus, I suggest you read a little bit on this How to Ask Questions The Smart Way article.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.