C++ : need quick tips for easy histogram

Discussion in 'C++' started by trapeze, Sep 7, 2007.

  1. trapeze

    trapeze New Member

    Joined:
    Sep 7, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    i'm stuck with assignment...

    i am trying to do easy histogram with x-axis info(like number options) and y-axis info(like # of occurrence) all within a figure by C++. however, i've no ideas to proceed at all.

    i am thinking about the following data: x-axis values are 1,2, and 3. y-axis values are 3, 7, and 4 for each x value respectively.

    i hope to hear you guys. great thx.
     
  2. trapeze

    trapeze New Member

    Joined:
    Sep 7, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    if the above is too easy, please help me out w/ the folowing:

    Code:
    #include<iostream>
    using namespace std;
    
    int main()
    {
    
    int i;
    int j;
    int k;
    int occurrence[10]={0,0,0,0,0,0,0,0,0,0};
    int data[10]={6,14,82,42,46,32,97,44,27,68};
    for (j=0; j<10; j++)
      { 
        for (i=0; i<10; i++)
            { 
              if ((data[j] >= 10*i) && (data[j] < 10*i+9)) 
                 occurrence[i]++;
            }
      } 
    cout << "occurrence # is ";
    for (k=0; k<10; k++)
    cout << occurrence[k]<<" "; 
    
    }
    
    
    ----------------------------------------------------------
    i don't know how to plot. i can't find the funtions. x-axis is 0-9,10-19,..,90-99. y-axis is the result above.

    also, how can i generate zero array at once for occurrence w/o typing them out ?

    great thx !
     
  3. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    For plotting you need to be doing some graphics fucntions and can you tell what OS and compiler you are using.
     
  4. trapeze

    trapeze New Member

    Joined:
    Sep 7, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    THX !

    WinXP 2.0
    Dev-C++
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice