I am trying to write a graph in standard output, the program returns rows of "#" that should add up to the initial quantity after another function changes them. I guarantee that the function that modifies the numbers is not at fault. This is my code :
struct mystruct {
long long int s;
long long int i;
long long int r;
}
mystruct initial_;
void draw_row(mystruct P)
{
long long int Ntotal = initial_.s + initial_.i;
int scale = round(Ntotal / 10);
std::string a(Ntotal / scale, '#');
std::string b(round(P.s / scale), '#');
std::string c(round(P.i / scale), '#');
std::string d(round(P.r / scale), '#');
std::cout << P.s << " " << P.i << " " << P.r << '\n';
std::cout << scale << '\n';
std::cout << a << '\n' << b << c << d << '\n';
}
These are examples of some of its outputs :
499 1 0
##########
#########
0 450 50
##########
##########
0 249 251
##########
#########