making a bar graph:

I am trying to compare two vectors and make a bar graph. I have tried sorting it and pushing it into another vector but this issue is when I go to output it. My logic is wrong. Any advice?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <iomanip>

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

    std::vector<int>num;
    std::vector<int>compare;
    int lottoNum;
    
    
   
    
    for (int i = 1; i<50; ++i) {compare.push_back(i); } //pushing int into vector 1-49
    
    std::ifstream infile("textfile.txt"); //opening lotto numbers
    
    while (infile>>lottoNum) { num.push_back(lottoNum); } //pushing numbers from file into vector
    
    for (auto it = num.begin(); it!=num.end(); ++it)
    {
        for (auto i = compare.begin(); i != compare.end(); ++i) {
            
            if (*it == *i) {
        
                std::cout<<*it<<std::setw(2)<<"*"<<"\n";
            }
        }
    }
    
    
    infile.close();
    
    return 0;
}


Output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 *
44 *
22 *
45 *
33 *
44 *
18 *
34 *
33 *
12 *
3 *
5 *
34 *
33 *
5 *
7 *
22 *
44 *
49 *
9 *
18 *
Tell us, what is wrong with your current bar graph and what is it you want it to show?
Look at the output line 1 has 22 and line 3 has 22. I want it to look like:

22 **

etc....
Never mind I got it. I was being a boob....
Topic archived. No new replies allowed.