I'm making a small program which will print out a quadratic graph as ascii "art" using / - and . I have two if statements and an else statement set up to test if the first point on the graph is going up, down or neither and one of the statements refuses to execute.
if (values[1]<values[0]-1.5){
slope[0]="\\";
}
if (values[1]>values[0]+1.5){
slope[0]="/";
}
else{
slopes[0]="-";
}
cout << slopes[0];
values is an array of each value in the specified domain and slopes is a list of each value's ascii character
the code outputs / for me if values[0] is over 1.5 less than values[1] but outputs - for anything else. Even if I rearrange the if statements the first one always seems to be ignored.
Aucun commentaire:
Enregistrer un commentaire